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

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.

ConstantValueDescription
QMediaPlaylist::NoError0No errors.
QMediaPlaylist::FormatError1Format error.
QMediaPlaylist::FormatNotSupportedError2Format not supported.
QMediaPlaylist::NetworkError3Network error.
QMediaPlaylist::AccessDeniedError4Access denied error.

enum QMediaPlaylist::PlaybackMode

The QMediaPlaylist::PlaybackMode describes the order items in playlist are played.

ConstantValueDescription
QMediaPlaylist::CurrentItemOnce0The current item is played only once.
QMediaPlaylist::CurrentItemInLoop1The current item is played repeatedly in a loop.
QMediaPlaylist::Sequential2Playback 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::Loop3Playback restarts at the first item after the last has finished playing.
QMediaPlaylist::Random4Play 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.