CopperSpice API  1.9.1
QMediaPlaylist Class Reference

Provides a list of media content to play. More...

Inheritance diagram for QMediaPlaylist:
QObject QMediaBindableInterface

Public Types

enum  Error
 
enum  PlaybackMode
 

Public Signals

void currentIndexChanged (int index)
 
void currentMediaChanged (const QMediaContent &content)
 
void loaded ()
 
void loadFailed ()
 
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)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Slots

void next ()
 
void previous ()
 
void setCurrentIndex (int index)
 
void shuffle ()
 
- Public Slots inherited from QObject
void deleteLater ()
 

Public Methods

 QMediaPlaylist (QObject *parent=nullptr)
 
virtual ~QMediaPlaylist ()
 
bool addMedia (const QList< QMediaContent > &items)
 
bool addMedia (const QMediaContent &content)
 
bool clear ()
 
int currentIndex () const
 
QMediaContent currentMedia () const
 
Error error () const
 
QString errorString () const
 
bool insertMedia (int index, const QList< QMediaContent > &items)
 
bool insertMedia (int index, const QMediaContent &content)
 
bool isEmpty () const
 
bool isReadOnly () const
 
void load (const QNetworkRequest &request, const char *format=nullptr)
 
void load (const QUrl &location, const char *format=nullptr)
 
void load (QIODevice *device, const char *format=nullptr)
 
QMediaContent media (int index) const
 
int mediaCount () const
 
QMediaObjectmediaObject () const override
 
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=nullptr)
 
bool save (QIODevice *device, const char *format)
 
void setPlaybackMode (PlaybackMode mode)
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QMediaBindableInterface
virtual ~QMediaBindableInterface ()
 

Protected Methods

bool setMediaObject (QMediaObject *object) override
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Properties

 currentIndex
 
 currentMedia
 
 playbackMode
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 

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.

Depending on playlist source implementation, most of the playlist mutating operations can be asynchronous.

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();
See also
QMediaContent

Member Enumeration Documentation

This enum describes the QMediaPlaylist error codes.

ConstantValueDescription
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.

ConstantValueDescription
QMediaPlaylist::CurrentItemOnce 0 Current item is played only once
QMediaPlaylist::CurrentItemInLoop 1 current item is 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

Constructor & Destructor Documentation

QMediaPlaylist::QMediaPlaylist ( QObject parent = nullptr)
explicit

Create a new playlist object with the given parent.

QMediaPlaylist::~QMediaPlaylist ( )
virtual

Destroys the playlist.

Method Documentation

bool QMediaPlaylist::addMedia ( const QList< QMediaContent > &  items)

Append multiple media content items to the playlist. Returns true if the operation is successful, otherwise returns false.

bool QMediaPlaylist::addMedia ( const QMediaContent content)

Append the media content to the playlist. Returns true if the operation is successful, otherwise returns false.

bool QMediaPlaylist::clear ( )

Remove all the items from the playlist. Returns true if the operation is successful, otherwise return false.

int QMediaPlaylist::currentIndex ( ) const

Returns position of the current media content in the playlist.

void QMediaPlaylist::currentIndexChanged ( int  index)
signal

Signal emitted when playlist position is changed to the given index.

QMediaContent QMediaPlaylist::currentMedia ( ) const

Returns the current media content.

void QMediaPlaylist::currentMediaChanged ( const QMediaContent content)
signal

Signal emitted when current media changes to content.

QMediaPlaylist::Error QMediaPlaylist::error ( ) const

Returns the last error condition.

QString QMediaPlaylist::errorString ( ) const

Returns the string describing the last error condition.

bool QMediaPlaylist::insertMedia ( int  index,
const QList< QMediaContent > &  items 
)

Insert multiple media content items to the playlist at the given index. Returns true if the operation is successful, otherwise returns false.

bool QMediaPlaylist::insertMedia ( int  index,
const QMediaContent content 
)

Insert the media content to the playlist at the given index. Returns true if the operation is successful, otherwise returns false.

bool QMediaPlaylist::isEmpty ( ) const

Returns true if the playlist contains no items, otherwise returns false.

See also
mediaCount()
bool QMediaPlaylist::isReadOnly ( ) const

Returns true if the playlist can be modified, otherwise returns false.

See also
mediaCount()
void QMediaPlaylist::load ( const QNetworkRequest request,
const char *  format = nullptr 
)

Load a playlist using the given request. If the format is specified then it will be used, otherwise the file format is deduced from the contents of the response.

New items are appended to playlist. QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed().

void QMediaPlaylist::load ( const QUrl location,
const char *  format = nullptr 
)

Load a playlist from the given location. If format is specified then it will be used, otherwise the file format is deduced from the location name and contents.

New items are appended to playlist. QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed().

void QMediaPlaylist::load ( QIODevice device,
const char *  format = nullptr 
)

Load a playlist from the given device. If the format is specified then it will be used, otherwise the file format is deduced from the contents of the file.

New items are appended to the playlist. QMediaPlaylist::loaded() signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed().

void QMediaPlaylist::loaded ( )
signal

Signal emitted when playlist finished loading.

void QMediaPlaylist::loadFailed ( )
signal

Signal emitted if failed to load playlist.

QMediaContent QMediaPlaylist::media ( int  index) const

Returns the media content at index in the playlist.

void QMediaPlaylist::mediaAboutToBeInserted ( int  start,
int  end 
)
signal

Signal emitted when items are to be inserted at start and ending at end.

void QMediaPlaylist::mediaAboutToBeRemoved ( int  start,
int  end 
)
signal

Signal emitted when item are to be deleted at start and ending at end.

void QMediaPlaylist::mediaChanged ( int  start,
int  end 
)
signal

This signal is emitted after media has been changed in the playlist between start and end positions inclusive.

int QMediaPlaylist::mediaCount ( ) const

Returns the number of items in the playlist.

See also
isEmpty()
void QMediaPlaylist::mediaInserted ( int  start,
int  end 
)
signal

This signal is emitted after media has been inserted into the playlist. The new items are those between start and end inclusive.

QMediaObject * QMediaPlaylist::mediaObject ( ) const
overridevirtual

Returns the QMediaObject instance this QMediaPlaylist is bound to, otherwise return 0.

Implements QMediaBindableInterface::mediaObject()

void QMediaPlaylist::mediaRemoved ( int  start,
int  end 
)
signal

This signal is emitted after media has been removed from the playlist. The removed items are those between start and end inclusive.

void QMediaPlaylist::next ( )
slot

Advance to the next media content in playlist.

int QMediaPlaylist::nextIndex ( int  steps = 1) const

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.

See also
QMediaPlaylist::playbackMode(), previousIndex()
PlaybackMode QMediaPlaylist::playbackMode ( ) const

Returns the value of the property playbackMode.

void QMediaPlaylist::playbackModeChanged ( QMediaPlaylist::PlaybackMode  mode)
signal

Signal emitted when playback mode changed to mode.

void QMediaPlaylist::previous ( )
slot

Return to the previous media content in playlist.

int QMediaPlaylist::previousIndex ( int  steps = 1) const

Returns the index of the item, which would be current after calling previous() steps times.

See also
QMediaPlaylist::playbackMode(), nextIndex()
bool QMediaPlaylist::removeMedia ( int  pos)

Remove the item from the playlist at position pos. Returns true if the operation is successful, otherwise return false.

bool QMediaPlaylist::removeMedia ( int  start,
int  end 
)

Remove items in the playlist from start to end inclusive. Returns true if the operation is successful, otherwise return false.

bool QMediaPlaylist::save ( const QUrl location,
const char *  format = nullptr 
)

Save a playlist to the given location. If the format is specified then it will be used, otherwise the file format is deduced from the contents of the location name. Returns true if playlist was saved successfully, otherwise returns false.

bool QMediaPlaylist::save ( QIODevice device,
const char *  format 
)

Save a playlist to the given device using the file format. Returns true if playlist was saved successfully, otherwise returns false.

void QMediaPlaylist::setCurrentIndex ( int  index)
slot

Activate media content from the playlist at the given index.

bool QMediaPlaylist::setMediaObject ( QMediaObject object)
overrideprotectedvirtual

Attaches to the media object. Returns true if attached successfully, otherwise returns false.

Implements QMediaBindableInterface::setMediaObject()

void QMediaPlaylist::setPlaybackMode ( PlaybackMode  mode)

Sets the value of the property to mode.

void QMediaPlaylist::shuffle ( )
slot

Shuffle items in the playlist.

Property Documentation

QMediaPlaylist::currentIndex

Current position.

PropertiesClass Methods
read currentIndex
write setCurrentIndex
notify currentIndexChanged
QMediaPlaylist::currentMedia

Current media content.

PropertiesClass Methods
read currentMedia
notify currentMediaChanged
QMediaPlaylist::playbackMode

This property defines the order that items in the playlist are played.

See also
QMediaPlaylist::PlaybackMode
PropertiesClass Methods
read playbackMode
write setPlaybackMode
notify playbackModeChanged