src/multimedia/qmediaplaylist_p.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_P_H
       
    43 #define QMEDIAPLAYLIST_P_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API. It exists purely as an
       
    50 // implementation detail. This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 
       
    56 #include "qmediaplaylist.h"
       
    57 #include "qmediaplaylistcontrol.h"
       
    58 #include "qmediaplayer.h"
       
    59 #include "qmediaplayercontrol.h"
       
    60 #include "qlocalmediaplaylistprovider.h"
       
    61 #include "qmediaobject_p.h"
       
    62 
       
    63 #include <QtCore/qdebug.h>
       
    64 
       
    65 #ifdef Q_MOC_RUN
       
    66 # pragma Q_MOC_EXPAND_MACROS
       
    67 #endif
       
    68 
       
    69 QT_BEGIN_NAMESPACE
       
    70 
       
    71 class QMediaPlaylistControl;
       
    72 class QMediaPlaylistProvider;
       
    73 class QMediaPlaylistReader;
       
    74 class QMediaPlaylistWriter;
       
    75 class QMediaPlayerControl;
       
    76 
       
    77 class QMediaPlaylistPrivate
       
    78 {
       
    79     Q_DECLARE_PUBLIC(QMediaPlaylist)
       
    80 public:
       
    81     QMediaPlaylistPrivate()
       
    82         :mediaObject(0),
       
    83         control(0),
       
    84         localPlaylistControl(0),
       
    85         error(QMediaPlaylist::NoError)
       
    86     {
       
    87     }
       
    88 
       
    89     virtual ~QMediaPlaylistPrivate() {}
       
    90 
       
    91     void _q_loadFailed(QMediaPlaylist::Error error, const QString &errorString)
       
    92     {
       
    93         this->error = error;
       
    94         this->errorString = errorString;
       
    95 
       
    96         emit q_ptr->loadFailed();
       
    97     }
       
    98 
       
    99     void _q_mediaObjectDeleted()
       
   100     {
       
   101         Q_Q(QMediaPlaylist);
       
   102         mediaObject = 0;
       
   103         if (control != localPlaylistControl)
       
   104             control = 0;
       
   105         q->setMediaObject(0);
       
   106     }
       
   107 
       
   108     QMediaObject *mediaObject;
       
   109 
       
   110     QMediaPlaylistControl *control;
       
   111     QMediaPlaylistProvider *playlist() const { return control->playlistProvider(); }
       
   112 
       
   113     QMediaPlaylistControl *localPlaylistControl;
       
   114 
       
   115     bool readItems(QMediaPlaylistReader *reader);
       
   116     bool writeItems(QMediaPlaylistWriter *writer);
       
   117 
       
   118     QMediaPlaylist::Error error;
       
   119     QString errorString;
       
   120 
       
   121     QMediaPlaylist *q_ptr;
       
   122 };
       
   123 
       
   124 
       
   125 class QLocalMediaPlaylistControl : public QMediaPlaylistControl
       
   126 {
       
   127     Q_OBJECT
       
   128 public:
       
   129     QLocalMediaPlaylistControl(QObject *parent)
       
   130         :QMediaPlaylistControl(parent)
       
   131     {
       
   132         QMediaPlaylistProvider *playlist = new QLocalMediaPlaylistProvider(this);
       
   133         m_navigator = new QMediaPlaylistNavigator(playlist,this);
       
   134         m_navigator->setPlaybackMode(QMediaPlaylist::Sequential);
       
   135 
       
   136         connect(m_navigator, SIGNAL(currentIndexChanged(int)), SIGNAL(currentIndexChanged(int)));
       
   137         connect(m_navigator, SIGNAL(activated(QMediaContent)), SIGNAL(currentMediaChanged(QMediaContent)));
       
   138     }
       
   139 
       
   140     virtual ~QLocalMediaPlaylistControl() {};
       
   141 
       
   142     QMediaPlaylistProvider* playlistProvider() const { return m_navigator->playlist(); }
       
   143     bool setPlaylistProvider(QMediaPlaylistProvider *mediaPlaylist)
       
   144     {
       
   145         m_navigator->setPlaylist(mediaPlaylist);
       
   146         emit playlistProviderChanged();
       
   147         return true;
       
   148     }
       
   149 
       
   150     int currentIndex() const { return m_navigator->currentIndex(); }
       
   151     void setCurrentIndex(int position) { m_navigator->jump(position); }
       
   152     int nextIndex(int steps) const { return m_navigator->nextIndex(steps); }
       
   153     int previousIndex(int steps) const { return m_navigator->previousIndex(steps); }
       
   154 
       
   155     void next() { m_navigator->next(); }
       
   156     void previous() { m_navigator->previous(); }
       
   157 
       
   158     QMediaPlaylist::PlaybackMode playbackMode() const { return m_navigator->playbackMode(); }
       
   159     void setPlaybackMode(QMediaPlaylist::PlaybackMode mode) { m_navigator->setPlaybackMode(mode); }
       
   160 
       
   161 private:
       
   162     QMediaPlaylistNavigator *m_navigator;
       
   163 };
       
   164 
       
   165 
       
   166 QT_END_NAMESPACE
       
   167 
       
   168 #endif // QMEDIAPLAYLIST_P_H