qtmobility/src/multimedia/qmediaplaylist.h
changeset 1 2b40d63a9c3d
child 4 90517678cc4f
equal deleted inserted replaced
0:cfcbf08528c4 1:2b40d63a9c3d
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 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 
       
    50 
       
    51 QTM_BEGIN_NAMESPACE
       
    52 
       
    53 class QMediaPlaylistProvider;
       
    54 
       
    55 class QMediaPlaylistPrivate;
       
    56 class Q_MEDIA_EXPORT QMediaPlaylist : public QObject
       
    57 {
       
    58     Q_OBJECT
       
    59     Q_PROPERTY(QMediaPlaylist::PlaybackMode playbackMode READ playbackMode WRITE setPlaybackMode NOTIFY playbackModeChanged)
       
    60     Q_PROPERTY(QMediaContent currentMedia READ currentMedia NOTIFY currentMediaChanged)
       
    61     Q_PROPERTY(int currentIndex READ currentIndex WRITE setCurrentIndex NOTIFY currentIndexChanged)
       
    62     Q_ENUMS(PlaybackMode Error)
       
    63 
       
    64 public:
       
    65     enum PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Linear, Loop, Random };
       
    66     enum Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError };
       
    67 
       
    68     QMediaPlaylist(QObject *parent = 0);
       
    69     virtual ~QMediaPlaylist();
       
    70 
       
    71     QMediaObject *mediaObject() const;
       
    72     void setMediaObject(QMediaObject *object);
       
    73 
       
    74     PlaybackMode playbackMode() const;
       
    75     void setPlaybackMode(PlaybackMode mode);
       
    76 
       
    77     int currentIndex() const;
       
    78     QMediaContent currentMedia() const;
       
    79 
       
    80     int nextIndex(int steps = 1) const;
       
    81     int previousIndex(int steps = 1) const;
       
    82 
       
    83     QMediaContent media(int index) const;
       
    84 
       
    85     int mediaCount() const;
       
    86     bool isEmpty() const;
       
    87     bool isReadOnly() const;
       
    88 
       
    89     bool addMedia(const QMediaContent &content);
       
    90     bool addMedia(const QList<QMediaContent> &items);
       
    91     bool insertMedia(int index, const QMediaContent &content);
       
    92     bool insertMedia(int index, const QList<QMediaContent> &items);
       
    93     bool removeMedia(int pos);
       
    94     bool removeMedia(int start, int end);
       
    95     bool clear();
       
    96 
       
    97     void load(const QUrl &location, const char *format = 0);
       
    98     void load(QIODevice * device, const char *format = 0);
       
    99 
       
   100     bool save(const QUrl &location, const char *format = 0);
       
   101     bool save(QIODevice * device, const char *format);
       
   102 
       
   103     Error error() const;
       
   104     QString errorString() const;
       
   105 
       
   106 public Q_SLOTS:
       
   107     void shuffle();
       
   108 
       
   109     void next();
       
   110     void previous();
       
   111 
       
   112     void setCurrentIndex(int index);
       
   113 
       
   114 Q_SIGNALS:
       
   115     void currentIndexChanged(int index);
       
   116     void playbackModeChanged(QMediaPlaylist::PlaybackMode mode);
       
   117     void currentMediaChanged(const QMediaContent&);
       
   118 
       
   119     void mediaAboutToBeInserted(int start, int end);
       
   120     void mediaInserted(int start, int end);
       
   121     void mediaAboutToBeRemoved(int start, int end);
       
   122     void mediaRemoved(int start, int end);
       
   123     void mediaChanged(int start, int end);
       
   124 
       
   125     void loaded();
       
   126     void loadFailed();
       
   127 
       
   128 protected:
       
   129     QMediaPlaylistPrivate *d_ptr;
       
   130 
       
   131 private:
       
   132     Q_DECLARE_PRIVATE(QMediaPlaylist)
       
   133     Q_PRIVATE_SLOT(d_func(), void _q_loadFailed(QMediaPlaylist::Error, const QString &))
       
   134 };
       
   135 
       
   136 QTM_END_NAMESPACE
       
   137 
       
   138 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QMediaPlaylist::PlaybackMode))
       
   139 Q_DECLARE_METATYPE(QTM_PREPEND_NAMESPACE(QMediaPlaylist::Error))
       
   140 
       
   141 
       
   142 #endif  // QMEDIAPLAYLIST_H