Playlist QML Type
For specifying a list of media to be played. More...
Import Statement: | import QtMultimedia 5.15 |
Since: | Qt 5.6 |
Properties
- currentIndex : int
- currentItemsource : url
- error : enumeration
- errorString : string
- itemCount : int
- playbackMode : enumeration
- readOnly : bool
Signals
- itemAboutToBeInserted(start, end)
- itemAboutToBeRemoved(start, end)
- itemChanged(start, end)
- itemInserted(start, end)
- itemRemoved(start, end)
- loadFailed()
- loaded()
Methods
- bool addItem(source)
- bool addItems(sources)
- bool clear()
- bool insertItem(index, source)
- bool insertItems(index, sources)
- url itemSource(index)
- load(location, format)
- bool moveItem(from, to)
- next()
- int nextIndex(steps)
- previous()
- int previousIndex(steps)
- bool removeItem(index)
- bool removeItems(int start, int end)
- bool save(location, format)
- shuffle()
Detailed Description
The Playlist type provides a way to play a list of media with the MediaPlayer, Audio and Video types. It can be used as a data source for view elements (such as ListView) and other elements that interact with model data (such as Repeater). When used as a data model, each playlist item's source URL can be accessed using the source
role.
Item { width: 400; height: 300; Audio { id: player; playlist: Playlist { id: playlist PlaylistItem { source: "song1.ogg"; } PlaylistItem { source: "song2.ogg"; } PlaylistItem { source: "song3.ogg"; } } } ListView { model: playlist; delegate: Text { font.pixelSize: 16; text: source; } } MouseArea { anchors.fill: parent; onPressed: { if (player.playbackState != Audio.PlayingState) { player.play(); } else { player.pause(); } } } }
See also MediaPlayer, Audio, and Video.
Property Documentation
This property holds the error condition of the playlist.
Value | Description |
---|---|
NoError | No errors |
FormatError | Format error. |
FormatNotSupportedError | Format not supported. |
NetworkError | Network error. |
AccessDeniedError | Access denied error. |
This property holds a string describing the current error condition of the playlist.
This property holds the order in which items in the playlist are played.
Value | Description |
---|---|
CurrentItemOnce | The current item is played only once. |
CurrentItemInLoop | The current item is played repeatedly in a loop. |
Sequential | 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. |
Loop | Playback restarts at the first item after the last has finished playing. |
Random | Play items in random order. |
Signal Documentation
This signal is emitted when items are to be inserted into the playlist at start and ending at end.
The corresponding handler is onItemAboutToBeInserted
.
Note: The corresponding handler is onItemAboutToBeInserted
.
This signal emitted when items are to be deleted from the playlist at start and ending at end.
The corresponding handler is onItemAboutToBeRemoved
.
Note: The corresponding handler is onItemAboutToBeRemoved
.
This signal is emitted after items have been changed in the playlist between start and end positions inclusive.
The corresponding handler is onItemChanged
.
Note: The corresponding handler is onItemChanged
.
This signal is emitted after items have been inserted into the playlist. The new items are those between start and end inclusive.
The corresponding handler is onItemInserted
.
Note: The corresponding handler is onItemInserted
.
This signal is emitted after items have been removed from the playlist. The removed items are those between start and end inclusive.
The corresponding handler is onMediaRemoved
.
Note: The corresponding handler is onItemRemoved
.
This signal is emitted when the playlist loading failed. error and errorString can be checked for more information on the failure.
The corresponding handler is onLoadFailed
.
Note: The corresponding handler is onLoadFailed
.
This signal is emitted when the playlist loading succeeded.
The corresponding handler is onLoaded
.
Note: The corresponding handler is onLoaded
.
Method Documentation
Appends the source URL to the playlist.
Returns true if the source is added successfully.
Appends the list of URLs in sources to the playlist.
Returns true if the sources are added successfully.
This method was introduced in Qt 5.7.
Inserts the source URL to the playlist at the given index.
Returns true if the source is added successfully.
Inserts the list of URLs in sources to the playlist at the given index.
Returns true if the sources are added successfully.
This method was introduced in Qt 5.7.
Loads a playlist from the given location. If format is specified, it is used, otherwise the format is guessed from the location name and the data.
New items are appended to the playlist.
onloaded()
is emitted if the playlist loads successfully, otherwise onLoadFailed()
is emitted with error and errorString defined accordingly.
Moves the item at index position from to index position to.
Returns true
if the item is moved successfully.
This method was introduced in Qt 5.7.
Returns the index of the item in the playlist which would be current after calling next() steps times.
Returned value depends on the size of the playlist, the current position and the playback mode.
See also playbackMode and previousIndex().
Returns the index of the item in the playlist which would be current after calling previous() steps times.
Returned value depends on the size of the playlist, the current position and the playback mode.
See also playbackMode and nextIndex().
Removes the item at the given index from the playlist.
Returns true
if the item is removed successfully.
Removes items in the playlist from start to end inclusive.
Returns true
if the items are removed successfully.
This method was introduced in Qt 5.7.
Saves the playlist to the given location. If format is specified, it is used, otherwise the format is guessed from the location name.
Returns true if the playlist is saved successfully.