The QMediaPlaylist class provides a list of media content to play. More...
#include <QMediaPlaylist>
Inherits: QObject and QMediaBindableInterface.
This class was introduced in Qt Mobility 1.0.
enum | Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError } |
enum | PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random } |
QMediaPlaylist ( QObject * parent = 0 ) | |
virtual | ~QMediaPlaylist () |
bool | addMedia ( const QMediaContent & content ) |
bool | addMedia ( const QList<QMediaContent> & items ) |
bool | clear () |
int | currentIndex () const |
QMediaContent | currentMedia () const |
Error | error () const |
QString | errorString () const |
bool | insertMedia ( int pos, const QMediaContent & content ) |
bool | insertMedia ( int pos, const QList<QMediaContent> & items ) |
bool | isEmpty () const |
bool | isReadOnly () const |
void | load ( const QUrl & location, const char * format = 0 ) |
void | load ( QIODevice * device, const char * format = 0 ) |
QMediaContent | media ( int index ) const |
int | mediaCount () const |
int | nextIndex ( int steps = 1 ) const |
PlaybackMode | playbackMode () const |
int | previousIndex ( int steps = 1 ) const |
bool | removeMedia ( int pos ) |
bool | removeMedia ( int start, int end ) |
bool | save ( const QUrl & location, const char * format = 0 ) |
bool | save ( QIODevice * device, const char * format ) |
void | setPlaybackMode ( PlaybackMode mode ) |
virtual QMediaObject * | mediaObject () const |
void | next () |
void | previous () |
void | setCurrentIndex ( int playlistPosition ) |
void | shuffle () |
void | currentIndexChanged ( int position ) |
void | currentMediaChanged ( const QMediaContent & content ) |
void | loadFailed () |
void | loaded () |
void | mediaAboutToBeInserted ( int start, int end ) |
void | mediaAboutToBeRemoved ( int start, int end ) |
void | mediaChanged ( int start, int end ) |
void | mediaInserted ( int start, int end ) |
void | mediaRemoved ( int start, int end ) |
void | playbackModeChanged ( QMediaPlaylist::PlaybackMode mode ) |
The QMediaPlaylist class provides a list of media content to play.
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.
playlist = new QMediaPlaylist; playlist->addMedia(QUrl("http://example.com/movie1.mp4")); playlist->addMedia(QUrl("http://example.com/movie2.mp4")); playlist->addMedia(QUrl("http://example.com/movie3.mp4")); playlist->setCurrentIndex(1); player = new QMediaPlayer; player->setPlaylist(playlist); videoWidget = new QVideoWidget; player->setVideoOutput(videoWidget); videoWidget->show(); player->play();
Depending on playlist source implementation, most of the playlist mutating operations can be asynchronous.
See also QMediaContent.
This enum describes the QMediaPlaylist error codes.
Constant | Value | Description |
---|---|---|
QMediaPlaylist::NoError | 0 | No errors. |
QMediaPlaylist::FormatError | 1 | Format error. |
QMediaPlaylist::FormatNotSupportedError | 2 | Format not supported. |
QMediaPlaylist::NetworkError | 3 | Network error. |
QMediaPlaylist::AccessDeniedError | 4 | Access denied error. |
The QMediaPlaylist::PlaybackMode describes the order items in playlist are played.
Constant | Value | Description |
---|---|---|
QMediaPlaylist::CurrentItemOnce | 0 | The current item is played only once. |
QMediaPlaylist::CurrentItemInLoop | 1 | The current item is played repeatedly in a loop. |
QMediaPlaylist::Sequential | 2 | 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. |
QMediaPlaylist::Loop | 3 | Playback restarts at the first item after the last has finished playing. |
QMediaPlaylist::Random | 4 | Play items in random order. |
This property holds current position.
This property was introduced in Qt Mobility 1.0.
Access functions:
int | currentIndex () const |
void | setCurrentIndex ( int playlistPosition ) |
Notifier signal:
void | currentIndexChanged ( int position ) |
This property holds current media content.
This property was introduced in Qt Mobility 1.0.
Access functions:
QMediaContent | currentMedia () const |
Notifier signal:
void | currentMediaChanged ( const QMediaContent & content ) |
This property defines the order, items in playlist are played.
This property was introduced in Qt Mobility 1.0.
Access functions:
PlaybackMode | playbackMode () const |
void | setPlaybackMode ( PlaybackMode mode ) |
Notifier signal:
void | playbackModeChanged ( QMediaPlaylist::PlaybackMode mode ) |
See also QMediaPlaylist::PlaybackMode.
Create a new playlist object for with the given parent.
Destroys the playlist.
Append the media content to the playlist.
Returns true if the operation is successful, otherwise return false.
This function was introduced in Qt Mobility 1.0.
Append multiple media content items to the playlist.
Returns true if the operation is successful, otherwise return false.
This function was introduced in Qt Mobility 1.0.
Remove all the items from the playlist.
Returns true if the operation is successful, otherwise return false.
This function was introduced in Qt Mobility 1.0.
Signal emitted when playlist position changed to position.
This function was introduced in Qt Mobility 1.0.
Signal emitted when current media changes to content.
This function was introduced in Qt Mobility 1.0.
Returns the last error condition.
This function was introduced in Qt Mobility 1.0.
Returns the string describing the last error condition.
This function was introduced in Qt Mobility 1.0.
Insert the media content to the playlist at position pos.
Returns true if the operation is successful, otherwise false.
This function was introduced in Qt Mobility 1.0.
Insert multiple media content items to the playlist at position pos.
Returns true if the operation is successful, otherwise false.
This function was introduced in Qt Mobility 1.0.
Returns true if the playlist contains no items; otherwise returns false.
This function was introduced in Qt Mobility 1.0.
See also mediaCount().
Returns true if the playlist can be modified; otherwise returns false.
This function was introduced in Qt Mobility 1.0.
See also mediaCount().
Load playlist from location. If format is specified, it is used, otherwise format is guessed from location name and data.
New items are appended to playlist.
QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed().
This function was introduced in Qt Mobility 1.0.
Load playlist from QIODevice device. If format is specified, it is used, otherwise format is guessed from device data.
New items are appended to playlist.
QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed().
This function was introduced in Qt Mobility 1.0.
Signal emitted if failed to load playlist.
This function was introduced in Qt Mobility 1.0.
Signal emitted when playlist finished loading.
This function was introduced in Qt Mobility 1.0.
Returns the media content at index in the playlist.
This function was introduced in Qt Mobility 1.0.
Signal emitted when items are to be inserted at start and ending at end.
This function was introduced in Qt Mobility 1.0.
Signal emitted when item are to be deleted at start and ending at end.
This function was introduced in Qt Mobility 1.0.
This signal is emitted after media has been changed in the playlist between start and end positions inclusive.
This function was introduced in Qt Mobility 1.0.
Returns the number of items in the playlist.
This function was introduced in Qt Mobility 1.0.
See also isEmpty().
This signal is emitted after media has been inserted into the playlist. The new items are those between start and end inclusive.
This function was introduced in Qt Mobility 1.0.
Reimplemented from QMediaBindableInterface::mediaObject().
Returns the QMediaObject instance that this QMediaPlaylist is bound too, or 0 otherwise.
This function was introduced in Qt Mobility 1.0.
This signal is emitted after media has been removed from the playlist. The removed items are those between start and end inclusive.
This function was introduced in Qt Mobility 1.0.
Advance to the next media content in playlist.
This function was introduced in Qt Mobility 1.0.
Returns the index of the item, which would be current after calling next() steps times.
Returned value depends on the size of playlist, current position and playback mode.
This function was introduced in Qt Mobility 1.0.
See also QMediaPlaylist::playbackMode.
Signal emitted when playback mode changed to mode.
This function was introduced in Qt Mobility 1.0.
Return to the previous media content in playlist.
This function was introduced in Qt Mobility 1.0.
Returns the index of the item, which would be current after calling previous() steps times.
This function was introduced in Qt Mobility 1.0.
See also QMediaPlaylist::playbackMode.
Remove the item from the playlist at position pos.
Returns true if the operation is successful, otherwise return false.
This function was introduced in Qt Mobility 1.0.
Remove items in the playlist from start to end inclusive.
Returns true if the operation is successful, otherwise return false.
This function was introduced in Qt Mobility 1.0.
Save playlist to location. If format is specified, it is used, otherwise format is guessed from location name.
Returns true if playlist was saved successfully, otherwise returns false.
This function was introduced in Qt Mobility 1.0.
Save playlist to QIODevice device using format format.
Returns true if playlist was saved successfully, otherwise returns false.
This function was introduced in Qt Mobility 1.0.
Shuffle items in the playlist.
This function was introduced in Qt Mobility 1.0.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.