用于指定要播放媒体的列表。 更多...
import 语句: | import QtMultimedia 5.8 |
Since: | Qt 5.6 |
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
角色。
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(); } } } }
另请参阅 MediaPlayer , 音频 ,和 视频 .
This property holds the position of the current item in the playlist.
currentItemsource : url |
This property holds the source URL of the current item in the playlist.
This property holds the error condition of the playlist.
值 | 描述 |
---|---|
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 number of items in the playlist.
This property holds the order in which items in the playlist are played.
值 | 描述 |
---|---|
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. |
This property indicates if the playlist can be modified.
This signal is emitted when items are to be inserted into the playlist at start and ending at end .
相应处理程序是
onItemAboutToBeInserted
.
This signal emitted when items are to be deleted from the playlist at start and ending at end .
相应处理程序是
onItemAboutToBeRemoved
.
This signal is emitted after items have been changed in the playlist between start and end positions inclusive.
相应处理程序是
onItemChanged
.
This signal is emitted after items have been inserted into the playlist. The new items are those between start and end 包括在内。
相应处理程序是
onItemInserted
.
This signal is emitted after items have been removed from the playlist. The removed items are those between start and end 包括在内。
相应处理程序是
onMediaRemoved
.
This signal is emitted when the playlist loading failed. error and errorString can be checked for more information on the failure.
相应处理程序是
onLoadFailed
.
This signal is emitted when the playlist loading succeeded.
相应处理程序是
onLoaded
.
追加 source URL to the playlist.
返回 true 若 source is added successfully.
Appends the list of URLs in sources to the playlist.
返回 true 若 sources are added successfully.
This QML method was introduced in Qt 5.7.
Removes all the items from the playlist.
Returns true if the operation is successful.
插入 source URL to the playlist at the given index .
返回 true 若 source is added successfully.
Inserts the list of URLs in sources to the playlist at the given index .
返回 true 若 sources are added successfully.
This QML method was introduced in Qt 5.7.
url itemSource ( index ) |
Returns the source URL of the item at the given index in the playlist.
Loads a playlist from the given location 。若 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.
移动项按索引位置 from 到索引位置 to .
Returns true if the item is moved successfully.
This QML method was introduced in Qt 5.7.
Advances to the next item in the playlist.
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.
另请参阅 playbackMode and previousIndex() .
Returns to the previous item in the playlist.
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.
另请参阅 playbackMode and nextIndex() .
Removed the item at the given index from the playlist.
返回 true 若 source is removed successfully.
Removes items in the playlist from start to end 包括在内。
Returns true if the items are removed successfully.
This QML method was introduced in Qt 5.7.
Saves the playlist to the given location 。若 format is specified, it is used, otherwise the format is guessed from the location name.
Returns true if the playlist is saved successfully.
Shuffles items in the playlist.