Qt Multimedia::QMediaPlayer类的介绍

这是一个播放多媒体流的类

几个重要的枚举类型

enum QMediaPlayer::MediaStatus

Defines the status of a media player's current media.

ConstantValueDescription
QMediaPlayer::UnknownMediaStatus0The status of the media cannot be determined.
QMediaPlayer::NoMedia1The is no current media. The player is in the StoppedState.
QMediaPlayer::LoadingMedia2The current media is being loaded. The player may be in any state.
QMediaPlayer::LoadedMedia3The current media has been loaded. The player is in the StoppedState.
QMediaPlayer::StalledMedia4Playback of the current media has stalled due to insufficient buffering or some other temporary interruption. The player is in thePlayingState orPausedState.
QMediaPlayer::BufferingMedia5The player is buffering data but has enough data buffered for playback to continue for the immediate future. The player is in thePlayingState orPausedState.
QMediaPlayer::BufferedMedia6The player has fully buffered the current media. The player is in thePlayingState or PausedState.
QMediaPlayer::EndOfMedia7Playback has reached the end of the current media. The player is in theStoppedState.
QMediaPlayer::InvalidMedia8The current media cannot be played. The player is in the StoppedState.

Properties:

  • audioAvailable : const bool     音频是否有效   notifier信号 void audioAvailableChanged(bool available)
  • bufferStatus : const int     This property holds the percentage of the temporary buffer filled before playback begins or resumes, from (empty) to (full)
  • currentMedia : const QMediaContent  当前正在播放的媒体的内容
  • duration : const qint64    当前媒体的duration  notifier信号   void durationChanged(qint64 duration)
  • error : const QString    a string describing the last error condition
  • media : QMediaContent   a string describing the last error condition
  • mediaStatus : const MediaStatus 当前媒体流的状态   notifier信号 voidmediaStatusChanged(QMediaPlayer::MediaStatus status)
  • muted : bool    是否静音 isMuted();setMuted()  notifier信号  void mutedChanged(bool muted)
  • playbackRate : qreal  播放速率;1是正常速率,大于1加快播放  void setPlaybackRate(qreal rate);notifier信号 void playbackRateChanged(qreal rate)
  • position : qint64  决定当前视频的播放位置(ms) void setPosition(qint64 position) notifier信号 voidpositionChanged(qint64 position)
  • seekable : const bool may change across the life time of the QMediaPlayer object, use the seekableChanged() signal to monitor changes.
  • state : const State 播放器的播放状态  notifer signal void stateChanged(QMediaPlayer::State state)
  • videoAvailable : const bool 
  • volume : int  The playback volume is linear in effect and the value can range from 0 - 100  notifer signal voidvolumeChanged(int volume)

公有成员函数

 QMediaPlayer(QObject * parent = 0, Flags flags = 0)
 ~QMediaPlayer()
intbufferStatus() const
QMediaContentcurrentMedia() const
QNetworkConfigurationcurrentNetworkConfiguration() const
qint64duration() const
Errorerror() const
QStringerrorString() const
boolisAudioAvailable() const
boolisMuted() const
boolisSeekable() const
boolisVideoAvailable() const
QMediaContentmedia() const
MediaStatusmediaStatus() const
const QIODevice *mediaStream() const
qrealplaybackRate() const
QMediaPlaylist *playlist() const
qint64position() const
voidsetVideoOutput(QVideoWidget * output) Attach a QVideoWidget video output to the media player ,可替换新
voidsetVideoOutput(QGraphicsVideoItem * output)
voidsetVideoOutput(QAbstractVideoSurface * surface) Sets a video surface as the video output of a media player
Statestate() const
intvolume() const


公有槽

voidpause()
voidplay() 开始或重新开始播放当前媒体流
voidsetMedia(const QMediaContent & media, QIODevice * stream = 0)
voidsetMuted(bool muted)
voidsetNetworkConfigurations(const QList<QNetworkConfiguration> & configurations)
voidsetPlaybackRate(qreal rate)
voidsetPlaylist(QMediaPlaylist * playlist)
voidsetPosition(qint64 position)
voidsetVolume(int volume)
voidstop() Stop playing, and reset the play position to the beginning.

信号:

voidaudioAvailableChanged(bool available)
voidbufferStatusChanged(int percentFilled)
voidcurrentMediaChanged(const QMediaContent & media)
voiddurationChanged(qint64 duration)
voiderror(QMediaPlayer::Error error)
voidmediaChanged(const QMediaContent & media)
voidmediaStatusChanged(QMediaPlayer::MediaStatus status)
voidmutedChanged(bool muted)
voidnetworkConfigurationChanged(const QNetworkConfiguration & configuration)
voidplaybackRateChanged(qreal rate)
voidpositionChanged(qint64 position)
voidseekableChanged(bool seekable)
voidstateChanged(QMediaPlayer::State state)
voidvideoAvailableChanged(bool videoAvailable)
voidvolumeChanged(int volume)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值