qtmobility/src/multimedia/qmediaplaylist.cpp
changeset 14 6fbed849b4f4
parent 11 06b8e2af4411
--- a/qtmobility/src/multimedia/qmediaplaylist.cpp	Fri Jun 11 14:26:25 2010 +0300
+++ b/qtmobility/src/multimedia/qmediaplaylist.cpp	Wed Jun 23 19:08:38 2010 +0300
@@ -59,7 +59,7 @@
 QT_BEGIN_NAMESPACE
 
 Q_GLOBAL_STATIC_WITH_ARGS(QMediaPluginLoader, playlistIOLoader,
-        (QMediaPlaylistIOInterface_iid, QLatin1String("/playlistformats"), Qt::CaseInsensitive))
+        (QMediaPlaylistIOInterface_iid, QLatin1String("playlistformats"), Qt::CaseInsensitive))
 
 
 /*!
@@ -71,6 +71,7 @@
 
     QMediaPlaylist is intended to be used with other media objects,
     like QMediaPlayer or QMediaImageViewer.
+
     QMediaPlaylist allows to access the service intrinsic playlist functionality
     if available, otherwise it provides the the local memory playlist implementation.
 
@@ -78,18 +79,19 @@
     player = new QMediaPlayer;
 
     playlist = new QMediaPlaylist;
-    playlist->setMediaObject(player);
     playlist->append(QUrl("http://example.com/movie1.mp4"));
     playlist->append(QUrl("http://example.com/movie2.mp4"));
     playlist->append(QUrl("http://example.com/movie3.mp4"));
 
     playlist->setCurrentIndex(1);
 
+    player->setPlaylist(playlist);
+
     player->play();
 \endcode
 
-    Depending on playlist source implementation,
-    most of playlist modifcation operations can be asynchronous.
+    Depending on playlist source implementation, most of the playlist mutating
+    operations can be asynchronous.
 
     \sa QMediaContent
 */
@@ -102,12 +104,12 @@
 
     \value CurrentItemOnce    The current item is played only once.
 
-    \value CurrentItemInLoop  The current item is played in the loop.
+    \value CurrentItemInLoop  The current item is played repeatedly in a loop.
 
-    \value Linear             Playback starts from the first to the last items and stops.
-                              next item is a null item when the last one is currently playing.
+    \value Sequential         Playback starts from the current and moves through each successive item until the last is reached and then stops.
+                              The next item is a null item when the last one is currently playing.
 
-    \value Loop               Playback continues from the first item after the last one finished playing.
+    \value Loop               Playback restarts at the first item after the last has finished playing.
 
     \value Random             Play items in random order.
 */
@@ -153,12 +155,12 @@
   If \a mediaObject is null or doesn't have an intrinsic playlist,
   internal local memory playlist source will be created.
 */
-void QMediaPlaylist::setMediaObject(QMediaObject *mediaObject)
+bool QMediaPlaylist::setMediaObject(QMediaObject *mediaObject)
 {
     Q_D(QMediaPlaylist);
 
     if (mediaObject && mediaObject == d->mediaObject)
-        return;
+        return true;
 
     QMediaService *service = mediaObject
             ? mediaObject->service() : 0;
@@ -166,7 +168,7 @@
     QMediaPlaylistControl *newControl = 0;
 
     if (service)
-        newControl = qobject_cast<QMediaPlaylistControl*>(service->control(QMediaPlaylistControl_iid));
+        newControl = qobject_cast<QMediaPlaylistControl*>(service->requestControl(QMediaPlaylistControl_iid));
 
     if (!newControl)
         newControl = d->localPlaylistControl;
@@ -193,6 +195,9 @@
                     this, SIGNAL(currentIndexChanged(int)));
             disconnect(d->control, SIGNAL(currentMediaChanged(QMediaContent)),
                     this, SIGNAL(currentMediaChanged(QMediaContent)));
+
+            if (d->mediaObject)
+                d->mediaObject->service()->releaseControl(d->control);
         }
 
         d->control = newControl;
@@ -224,12 +229,9 @@
         }
     }
 
-    if (d->mediaObject)
-        d->mediaObject->unbind(this);
+    d->mediaObject = mediaObject;
 
-    d->mediaObject = mediaObject;
-    if (d->mediaObject)
-        d->mediaObject->bind(this);
+    return true;
 }
 
 /*!
@@ -252,7 +254,7 @@
 }
 
 /*!
-  Returns position of the current media source in the playlist.
+  Returns position of the current media content in the playlist.
 */
 int QMediaPlaylist::currentIndex() const
 {
@@ -269,7 +271,7 @@
 }
 
 /*!
-  Returns the index of item, which were current after calling next()
+  Returns the index of the item, which would be current after calling next()
   \a steps times.
 
   Returned value depends on the size of playlist, current position
@@ -283,7 +285,7 @@
 }
 
 /*!
-  Returns the index of item, which were current after calling previous()
+  Returns the index of the item, which would be current after calling previous()
   \a steps times.
 
   \sa QMediaPlaylist::playbackMode
@@ -307,6 +309,7 @@
 
 /*!
   Returns true if the playlist contains no items; otherwise returns false.
+
   \sa size()
   */
 bool QMediaPlaylist::isEmpty() const
@@ -316,6 +319,7 @@
 
 /*!
   Returns true if the playlist can be modified; otherwise returns false.
+
   \sa size()
   */
 bool QMediaPlaylist::isReadOnly() const
@@ -335,7 +339,7 @@
 /*!
   Append the media \a content to the playlist.
 
-  Returns true if the operation is successfull, other wise return false.
+  Returns true if the operation is successful, otherwise return false.
   */
 bool QMediaPlaylist::addMedia(const QMediaContent &content)
 {
@@ -345,7 +349,7 @@
 /*!
   Append multiple media content \a items to the playlist.
 
-  Returns true if the operation is successfull, other wise return false.
+  Returns true if the operation is successful, otherwise return false.
   */
 bool QMediaPlaylist::addMedia(const QList<QMediaContent> &items)
 {
@@ -377,7 +381,7 @@
 /*!
   Remove the item from the playlist at position \a pos.
 
-  Returns true if the operation is successfull, other wise return false.
+  Returns true if the operation is successful, otherwise return false.
   */
 bool QMediaPlaylist::removeMedia(int pos)
 {
@@ -386,9 +390,9 @@
 }
 
 /*!
-  Remove the items from the playlist from position \a start to \a end inclusive.
+  Remove items in the playlist from \a start to \a end inclusive.
 
-  Returns true if the operation is successfull, other wise return false.
+  Returns true if the operation is successful, otherwise return false.
   */
 bool QMediaPlaylist::removeMedia(int start, int end)
 {
@@ -399,7 +403,7 @@
 /*!
   Remove all the items from the playlist.
 
-  Returns true if the operation is successfull, other wise return false.
+  Returns true if the operation is successful, otherwise return false.
   */
 bool QMediaPlaylist::clear()
 {
@@ -431,7 +435,7 @@
 
   New items are appended to playlist.
 
-  QMediaPlaylist::loaded() signal is emited if playlist was loaded succesfully,
+  QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
   otherwise the playlist emits loadFailed().
 */
 void QMediaPlaylist::load(const QUrl &location, const char *format)
@@ -477,7 +481,7 @@
 
   New items are appended to playlist.
 
-  QMediaPlaylist::loaded() signal is emited if playlist was loaded succesfully,
+  QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully,
   otherwise the playlist emits loadFailed().
 */
 void QMediaPlaylist::load(QIODevice * device, const char *format)
@@ -521,7 +525,7 @@
   Save playlist to \a location. If \a format is specified, it is used,
   otherwise format is guessed from location name.
 
-  Returns true if playlist was saved succesfully, otherwise returns false.
+  Returns true if playlist was saved successfully, otherwise returns false.
   */
 bool QMediaPlaylist::save(const QUrl &location, const char *format)
 {
@@ -547,7 +551,7 @@
 /*!
   Save playlist to QIODevice \a device using format \a format.
 
-  Returns true if playlist was saved succesfully, otherwise returns false.
+  Returns true if playlist was saved successfully, otherwise returns false.
 */
 bool QMediaPlaylist::save(QIODevice * device, const char *format)
 {
@@ -663,13 +667,13 @@
 /*!
     \fn void QMediaPlaylist::mediaAboutToBeInserted(int start, int end)
 
-    Signal emitted when item to be inserted at \a start and ending at \a end.
+    Signal emitted when items are to be inserted at \a start and ending at \a end.
 */
 
 /*!
     \fn void QMediaPlaylist::mediaAboutToBeRemoved(int start, int end)
 
-    Signal emitted when item to de deleted ar \a start and ending at \a end.
+    Signal emitted when item are to be deleted at \a start and ending at \a end.
 */
 
 /*!