diff options
author | Lev Zelenskiy <lev.zelenskiy@nokia.com> | 2012-03-05 12:25:50 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-12 05:29:56 +0100 |
commit | 87de0979e5ac91c7489c34b254de502d071bb72f (patch) | |
tree | eed477b964f33d34c9e091afa8e42a1cac82bcaa /src | |
parent | e2eaa283fb0494284304c12285c0d3c10086dfe6 (diff) |
Added playlist property to QMediaContent
This is a part of changes to QMediaPlayer related to playlist handling.
Updated unit test.
Change-Id: Ic2460dc4d3121788cd5eb08df71e6d45aac032bc
Reviewed-by: Michael Goddard <michael.goddard@nokia.com>
Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/multimedia/playback/qmediacontent.cpp | 64 | ||||
-rw-r--r-- | src/multimedia/playback/qmediacontent.h | 4 |
2 files changed, 62 insertions, 6 deletions
diff --git a/src/multimedia/playback/qmediacontent.cpp b/src/multimedia/playback/qmediacontent.cpp index bfcfdd627..641c7a485 100644 --- a/src/multimedia/playback/qmediacontent.cpp +++ b/src/multimedia/playback/qmediacontent.cpp @@ -41,7 +41,9 @@ #include <QtCore/qurl.h> #include <QtCore/qvariant.h> +#include <QtCore/QWeakPointer> +#include <qmediaplaylist.h> #include "qmediacontent.h" QT_BEGIN_NAMESPACE @@ -62,21 +64,44 @@ namespace class QMediaContentPrivate : public QSharedData { public: - QMediaContentPrivate() {} + QMediaContentPrivate(): + isPlaylistOwned(false) + {} + QMediaContentPrivate(const QMediaResourceList &r): - resources(r) {} + resources(r), + isPlaylistOwned(false) + {} QMediaContentPrivate(const QMediaContentPrivate &other): QSharedData(other), - resources(other.resources) + resources(other.resources), + playlist(other.playlist), + isPlaylistOwned(false) {} + QMediaContentPrivate(QMediaPlaylist *pls, const QUrl &url, bool isOwn): + playlist(pls), + isPlaylistOwned(isOwn) + { + resources << QMediaResource(url); + } + + ~QMediaContentPrivate() + { + if (isPlaylistOwned && !playlist.isNull()) + playlist.data()->deleteLater(); + } + bool operator ==(const QMediaContentPrivate &other) const { - return resources == other.resources; + return resources == other.resources && playlist == other.playlist; } - QMediaResourceList resources; + QMediaResourceList resources; + + QWeakPointer<QMediaPlaylist> playlist; + bool isPlaylistOwned; private: QMediaContentPrivate& operator=(const QMediaContentPrivate &other); }; @@ -99,6 +124,10 @@ private: A non-null QMediaContent will always have a primary or canonical reference to the content available through the canonicalUrl() or canonicalResource() methods, any additional resources are optional. + + Alternatively QMediaContent can represent a playlist and contain a pointer to a + valid QMediaPlaylist object. In this case URL is optional and can either be empty + or point to the playlist URL. */ @@ -162,6 +191,20 @@ QMediaContent::QMediaContent(const QMediaContent &other): } /*! + Constructs a media content with \a playlist. + + \a contentUrl of a playlist is an optional parameter and can be empty. + + Set \a takeOwnership to true if you want QMediaContent to take ownership of the playlist. + \a takeOwnership is set to false by default. +*/ + +QMediaContent::QMediaContent(QMediaPlaylist *playlist, const QUrl &contentUrl, bool takeOwnership): + d(new QMediaContentPrivate(playlist, contentUrl, takeOwnership)) +{ +} + +/*! Destroys the media content object. */ @@ -249,5 +292,16 @@ QMediaResourceList QMediaContent::resources() const : QMediaResourceList(); } +/*! + Returns a playlist for this media content or 0 if this QMediaContent is not a playlist. +*/ + +QMediaPlaylist *QMediaContent::playlist() const +{ + return d.constData() != 0 + ? d->playlist.data() + : 0; +} + QT_END_NAMESPACE diff --git a/src/multimedia/playback/qmediacontent.h b/src/multimedia/playback/qmediacontent.h index 546d2f4f9..7b1fbbbd6 100644 --- a/src/multimedia/playback/qmediacontent.h +++ b/src/multimedia/playback/qmediacontent.h @@ -49,13 +49,13 @@ #include <qtmultimediadefs.h> - QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Multimedia) +class QMediaPlaylist; class QMediaContentPrivate; class Q_MULTIMEDIA_EXPORT QMediaContent @@ -67,6 +67,7 @@ public: QMediaContent(const QMediaResource &contentResource); QMediaContent(const QMediaResourceList &resources); QMediaContent(const QMediaContent &other); + QMediaContent(QMediaPlaylist *playlist, const QUrl &contentUrl = QUrl(), bool takeOwnership = false); ~QMediaContent(); QMediaContent& operator=(const QMediaContent &other); @@ -82,6 +83,7 @@ public: QMediaResourceList resources() const; + QMediaPlaylist *playlist() const; private: QSharedDataPointer<QMediaContentPrivate> d; }; |