src/multimedia/qmediaplaylist.h
changeset 0 876b1a06bc25
equal deleted inserted replaced
-1:000000000000 0:876b1a06bc25
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the Qt Mobility Components.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QMEDIAPLAYLIST_H
       
    43 #define QMEDIAPLAYLIST_H
       
    44 
       
    45 #include <QtCore/qobject.h>
       
    46 
       
    47 #include <qmediacontent.h>
       
    48 #include <qmediaobject.h>
       
    49 #include <qmediabindableinterface.h>
       
    50 
       
    51 
       
    52 QT_BEGIN_NAMESPACE
       
    53 
       
    54 class QMediaPlaylistProvider;
       
    55 
       
    56 class QMediaPlaylistPrivate;
       
    57 class Q_MULTIMEDIA_EXPORT QMediaPlaylist : public QObject, public QMediaBindableInterface
       
    58 {
       
    59     Q_OBJECT
       
    60     Q_INTERFACES(QMediaBindableInterface)
       
    61     Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged)
       
    62     Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged)
       
    63     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
       
    64     Q_ENUMS(PlaybackMode Error)
       
    65 
       
    66 public:
       
    67     enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random };
       
    68     enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError };
       
    69 
       
    70     QMediaPlaylist(QObject *parent = 0);
       
    71     virtual ~QMediaPlaylist();
       
    72 
       
    73     QMediaObject *mediaObject() const;
       
    74 
       
    75     PlaybackMode playbackMode() const;
       
    76     void setPlaybackMode(PlaybackMode mode);
       
    77 
       
    78     int currentIndex() const;
       
    79     QMediaContent currentMedia() const;
       
    80 
       
    81     int nextIndex(int steps = 1) const;
       
    82     int previousIndex(int steps = 1) const;
       
    83 
       
    84     QMediaContent media(int index) const;
       
    85 
       
    86     int mediaCount() const;
       
    87     bool isEmpty() const;
       
    88     bool isReadOnly() const;
       
    89 
       
    90     bool addMedia(const QMediaContent &content);
       
    91     bool addMedia(const QList<QMediaContent> &items);
       
    92     bool insertMedia(int index, const QMediaContent &content);
       
    93     bool insertMedia(int index, const QList<QMediaContent> &items);
       
    94     bool removeMedia(int pos);
       
    95     bool removeMedia(int start, int end);
       
    96     bool clear();
       
    97 
       
    98     void load(const QUrl &location, const char *format = 0);
       
    99     void load(QIODevice * device, const char *format = 0);
       
   100 
       
   101     bool save(const QUrl &location, const char *format = 0);
       
   102     bool save(QIODevice * device, const char *format);
       
   103 
       
   104     Error error() const;
       
   105     QString errorString() const;
       
   106 
       
   107 public Q_SLOTS:
       
   108     void shuffle();
       
   109 
       
   110     void next();
       
   111     void previous();
       
   112 
       
   113     void setCurrentIndex(int index);
       
   114 
       
   115 Q_SIGNALS:
       
   116     void currentIndexChanged(int index);
       
   117     void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
       
   118     void currentMediaChanged(const QMediaContent&);
       
   119 
       
   120     void mediaAboutToBeInserted(int start, int end);
       
   121     void mediaInserted(int start, int end);
       
   122     void mediaAboutToBeRemoved(int start, int end);
       
   123     void mediaRemoved(int start, int end);
       
   124     void mediaChanged(int start, int end);
       
   125 
       
   126     void loaded();
       
   127     void loadFailed();
       
   128 
       
   129 protected:
       
   130     bool setMediaObject(QMediaObject *object);
       
   131     QMediaPlaylistPrivate *d_ptr;
       
   132 
       
   133 private:
       
   134     Q_DECLARE_PRIVATE(QMediaPlaylist)
       
   135     Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &))
       
   136 };
       
   137 
       
   138 QT_END_NAMESPACE
       
   139 
       
   140 Q_DECLARE_METATYPE(QMediaPlaylist::PlaybackMode)
       
   141 Q_DECLARE_METATYPE(QMediaPlaylist::Error)
       
   142 
       
   143 
       
   144 #endif  // QMEDIAPLAYLIST_H