篇首语:本文由小编为大家整理,主要介绍了Qt 之QMediaPlayer类详解相关的知识,希望对你有一定的参考价值。
这是一个播放多媒体流的类
几个重要的枚举类型
Defines the status of a media player's current media.
Constant | Value | Description |
---|---|---|
QMediaPlayer::UnknownMediaStatus | 0 | The status of the media cannot be determined. |
QMediaPlayer::NoMedia | 1 | The is no current media. The player is in the StoppedState. |
QMediaPlayer::LoadingMedia | 2 | The current media is being loaded. The player may be in any state. |
QMediaPlayer::LoadedMedia | 3 | The current media has been loaded. The player is in the StoppedState. |
QMediaPlayer::StalledMedia | 4 | Playback of the current media has stalled due to insufficient buffering or some other temporary interruption. The player is in thePlayingState or PausedState. |
QMediaPlayer::BufferingMedia | 5 | The player is buffering data but has enough data buffered for playback to continue for the immediate future. The player is in thePlayingState or PausedState. |
QMediaPlayer::BufferedMedia | 6 | The player has fully buffered the current media. The player is in thePlayingState or PausedState. |
QMediaPlayer::EndOfMedia | 7 | Playback has reached the end of the current media. The player is in theStoppedState. |
QMediaPlayer::InvalidMedia | 8 | The current media cannot be played. The player is in the StoppedState. |
公有成员函数
QMediaPlayer(QObject * parent = 0, Flags flags = 0) | |
~QMediaPlayer() | |
int | bufferStatus() const |
QMediaContent | currentMedia() const |
QNetworkConfiguration | currentNetworkConfiguration() const |
qint64 | duration() const |
Error | error() const |
QString | errorString() const |
bool | isAudioAvailable() const |
bool | isMuted() const |
bool | isSeekable() const |
bool | isVideoAvailable() const |
QMediaContent | media() const |
MediaStatus | mediaStatus() const |
const QIODevice * | mediaStream() const |
qreal | playbackRate() const |
QMediaPlaylist * | playlist() const |
qint64 | position() const |
void | setVideoOutput(QVideoWidget * output) Attach a QVideoWidget video output to the media player ,可替换新 |
void | setVideoOutput(QGraphicsVideoItem * output) |
void | setVideoOutput(QAbstractVideoSurface * surface) Sets a video surface as the video output of a media player |
State | state() const |
int | volume() const |
公有槽
void | pause() |
void | play() 开始或重新开始播放当前媒体流 |
void | setMedia(const QMediaContent & media, QIODevice * stream = 0) |
void | setMuted(bool muted) |
void | setNetworkConfigurations(const QList<QNetworkConfiguration> & configurations) |
void | setPlaybackRate(qreal rate) |
void | setPlaylist(QMediaPlaylist * playlist) |
void | setPosition(qint64 position) |
void | setVolume(int volume) |
void | stop() Stop playing, and reset the play position to the beginning. |
信号:
void | audioAvailableChanged(bool available) |
void | bufferStatusChanged(int percentFilled) |
void | currentMediaChanged(const QMediaContent & media) |
void | durationChanged(qint64 duration) |
void | error(QMediaPlayer::Error error) |
void | mediaChanged(const QMediaContent & media) |
void | mediaStatusChanged(QMediaPlayer::MediaStatus status) |
void | mutedChanged(bool muted) |
void | networkConfigurationChanged(const QNetworkConfiguration & configuration) |
void | playbackRateChanged(qreal rate) |
void | positionChanged(qint64 position) |
void | seekableChanged(bool seekable) |
void | stateChanged(QMediaPlayer::State state) |
void | videoAvailableChanged(bool videoAvailable) |
void | volumeChanged(int volume) |
以上是关于Qt 之QMediaPlayer类详解的主要内容,如果未能解决你的问题,请参考以下文章