QMediaPlaylist Class
The QMediaPlaylist class provides a list of media content to play. More...
| Header: | #include <QMediaPlaylist> |
| qmake: | QT += multimedia |
| Inherits: | QObject and QMediaBindableInterface |
Public Types
| enum | Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError } |
| enum | PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random } |
Properties
- currentIndex : int
- currentMedia : const QMediaContent
- playbackMode : QMediaPlaylist::PlaybackMode
Public Functions
| int | currentIndex() const |
| QMediaContent | currentMedia() const |
| QMediaPlaylist::PlaybackMode | playbackMode() const |
| void | setPlaybackMode(QMediaPlaylist::PlaybackMode mode) |
Public Slots
| void | setCurrentIndex(int index) |
Signals
| void | currentIndexChanged(int index) |
| void | currentMediaChanged(const QMediaContent &) |
| void | playbackModeChanged(QMediaPlaylist::PlaybackMode mode) |
Detailed Description
QMediaPlaylist is intended to be used with other media objects, like QMediaPlayer.
QMediaPlaylist allows to access the service intrinsic playlist functionality if available, otherwise it provides 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.
Member Type Documentation
enum QMediaPlaylist::Error
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. |
enum QMediaPlaylist::PlaybackMode
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. |
Property Documentation
currentIndex : int
Current position.
Access functions:
| int | currentIndex() const |
| void | setCurrentIndex(int index) |
Notifier signal:
| void | currentIndexChanged(int index) |
currentMedia : const QMediaContent
Current media content.
Access functions:
| QMediaContent | currentMedia() const |
Notifier signal:
| void | currentMediaChanged(const QMediaContent &) |
playbackMode : QMediaPlaylist::PlaybackMode
This property defines the order that items in the playlist are played.
Access functions:
| QMediaPlaylist::PlaybackMode | playbackMode() const |
| void | setPlaybackMode(QMediaPlaylist::PlaybackMode mode) |
Notifier signal:
| void | playbackModeChanged(QMediaPlaylist::PlaybackMode mode) |
See also QMediaPlaylist::PlaybackMode.