The QMediaPlaylist class provides a list of media content to play. 更多...
| 頭: | #include <QMediaPlaylist> |
| qmake: | QT += multimedia |
| 繼承: | QObject and QMediaBindableInterface |
| enum | Error { NoError, FormatError, FormatNotSupportedError, NetworkError, AccessDeniedError } |
| enum | PlaybackMode { CurrentItemOnce, CurrentItemInLoop, Sequential, Loop, Random } |
| QMediaPlaylist (QObject * parent = nullptr) | |
| virtual | ~QMediaPlaylist () |
| bool | addMedia (const QMediaContent & content ) |
| bool | addMedia (const QList<QMediaContent> & items ) |
| bool | clear () |
| int | currentIndex () const |
| QMediaContent | currentMedia () const |
| QMediaPlaylist::Error | error () const |
| QString | errorString () const |
| bool | insertMedia (int pos , const QMediaContent & content ) |
| bool | insertMedia (int pos , const QList<QMediaContent> & items ) |
| 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 |
| bool | moveMedia (int from , int to ) |
| int | nextIndex (int steps = 1) const |
| QMediaPlaylist::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 (QMediaPlaylist::PlaybackMode mode ) |
| virtual QMediaObject * | mediaObject () const override |
| void | next () |
| void | previous () |
| void | setCurrentIndex (int playlistPosition ) |
| void | shuffle () |
| void | currentIndexChanged (int position ) |
| void | currentMediaChanged (const QMediaContent & content ) |
| void | loadFailed () |
| void | loaded () |
| 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 ) |
| const QMetaObject | staticMetaObject |
| QMediaPlaylistPrivate * | d_ptr |
The QMediaPlaylist class provides a list of media content to play.
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.
另請參閱 QMediaContent .
此枚舉描述 QMediaPlaylist 錯誤代碼。
| 常量 | 值 | 描述 |
|---|---|---|
QMediaPlaylist::NoError
|
0
|
沒有錯誤。 |
QMediaPlaylist::FormatError
|
1
|
格式錯誤。 |
QMediaPlaylist::FormatNotSupportedError
|
2
|
格式不支持。 |
QMediaPlaylist::NetworkError
|
3
|
網絡錯誤。 |
QMediaPlaylist::AccessDeniedError
|
4
|
訪問被拒錯誤。 |
The QMediaPlaylist::PlaybackMode describes the order items in playlist are played.
| 常量 | 值 | 描述 |
|---|---|---|
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
|
按隨機次序播放項。 |
當前位置。
訪問函數:
| int | currentIndex () const |
| void | setCurrentIndex (int playlistPosition ) |
通知程序信號:
| void | currentIndexChanged (int position ) |
當前媒體內容。
訪問函數:
| QMediaContent | currentMedia () const |
通知程序信號:
| void | currentMediaChanged (const QMediaContent & content ) |
This property defines the order that items in the playlist are played.
訪問函數:
| QMediaPlaylist::PlaybackMode | playbackMode () const |
| void | setPlaybackMode (QMediaPlaylist::PlaybackMode mode ) |
通知程序信號:
| void | playbackModeChanged (QMediaPlaylist::PlaybackMode mode ) |
另請參閱 QMediaPlaylist::PlaybackMode .
創建新的 Playlist 對象采用給定 parent .
[虛擬]
QMediaPlaylist::
~QMediaPlaylist
()
銷毀 Playlist。
追加媒體 content 到播放列錶。
Returns true if the operation is successful, otherwise returns false.
追加多媒體內容 items 到播放列錶。
Returns true if the operation is successful, otherwise returns false.
Remove all the items from the playlist.
Returns true if the operation is successful, otherwise return false.
Returns position of the current media content in the playlist.
注意: getter 函數對於特性 currentIndex .
另請參閱 setCurrentIndex ().
[signal]
void
QMediaPlaylist::
currentIndexChanged
(
int
position
)
發射信號,當播放列錶位置變成 position .
注意: 通知程序信號對於特性 currentIndex .
返迴當前媒體內容。
注意: getter 函數對於特性 currentMedia .
[signal]
void
QMediaPlaylist::
currentMediaChanged
(const
QMediaContent
&
content
)
發射信號,當當前媒體變成 content .
注意: 通知程序信號對於特性 currentMedia .
Returns the last error condition.
Returns the string describing the last error condition.
插入媒體 content to the playlist at position pos .
Returns true if the operation is successful, otherwise returns false.
Insert multiple media content items to the playlist at position pos .
Returns true if the operation is successful, otherwise returns false.
Returns true if the playlist contains no items, otherwise returns false.
另請參閱 mediaCount ().
Returns true if the playlist can be modified, otherwise returns false.
另請參閱 mediaCount ().
Load playlist using network request 。若 format is specified, it is used, otherwise format is guessed from playlist name and data.
New items are appended to playlist.
QMediaPlaylist::loaded () signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed ().
加載播放列錶從 location 。若 format is specified, it is used, otherwise format is guessed from location name and data.
New items are appended to playlist.
QMediaPlaylist::loaded () signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed ().
加載播放列錶從 QIODevice device 。若 format is specified, it is used, otherwise format is guessed from device data.
New items are appended to playlist.
QMediaPlaylist::loaded () signal is emitted if playlist was loaded successfully, otherwise the playlist emits loadFailed ().
[signal]
void
QMediaPlaylist::
loadFailed
()
發射信號,若無法加載播放列錶。
[signal]
void
QMediaPlaylist::
loaded
()
Signal emitted when playlist finished loading.
Returns the media content at index in the playlist.
[signal]
void
QMediaPlaylist::
mediaAboutToBeInserted
(
int
start
,
int
end
)
Signal emitted when items are to be inserted at start and ending at end .
[signal]
void
QMediaPlaylist::
mediaAboutToBeRemoved
(
int
start
,
int
end
)
Signal emitted when item are to be deleted at start and ending at end .
[signal]
void
QMediaPlaylist::
mediaChanged
(
int
start
,
int
end
)
This signal is emitted after media has been changed in the playlist between start and end positions inclusive.
Returns the number of items in the playlist.
另請參閱 isEmpty ().
[signal]
void
QMediaPlaylist::
mediaInserted
(
int
start
,
int
end
)
This signal is emitted after media has been inserted into the playlist. The new items are those between start and end 包括在內。
[override virtual]
QMediaObject
*QMediaPlaylist::
mediaObject
() const
重實現自 QMediaBindableInterface::mediaObject ().
返迴 QMediaObject instance that this QMediaPlaylist is bound too, or 0 otherwise.
[signal]
void
QMediaPlaylist::
mediaRemoved
(
int
start
,
int
end
)
This signal is emitted after media has been removed from the playlist. The removed items are those between start and end 包括在內。
Move the item from position from to position to .
Returns true if the operation is successful, otherwise false.
該函數在 Qt 5.7 引入。
[slot]
void
QMediaPlaylist::
next
()
Advance to the next media content in playlist.
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.
另請參閱 QMediaPlaylist::playbackMode () 和 previousIndex ().
[signal]
void
QMediaPlaylist::
playbackModeChanged
(
QMediaPlaylist::PlaybackMode
mode
)
Signal emitted when playback mode changed to mode .
注意: 通知程序信號對於特性 playbackMode .
[slot]
void
QMediaPlaylist::
previous
()
Return to the previous media content in playlist.
Returns the index of the item, which would be current after calling previous () steps times.
另請參閱 QMediaPlaylist::playbackMode () 和 nextIndex ().
Remove the item from the playlist at position pos .
Returns true if the operation is successful, otherwise return false.
Remove items in the playlist from start to end 包括在內。
Returns true if the operation is successful, otherwise return false.
Save playlist to location 。若 format is specified, it is used, otherwise format is guessed from location name.
Returns true if playlist was saved successfully, otherwise returns false.
Save playlist to QIODevice device using format format .
Returns true if playlist was saved successfully, otherwise returns false.
[slot]
void
QMediaPlaylist::
setCurrentIndex
(
int
playlistPosition
)
Activate media content from playlist at position playlistPosition .
注意: setter 函數對於特性 currentIndex .
另請參閱 currentIndex ().
[slot]
void
QMediaPlaylist::
shuffle
()
洗牌播放列錶項。