Qt 之QMediaPlayer类详解 admin 2023-05-26 11:03:01 篇首语:本文由小编为大家整理,主要介绍了Qt 之QMediaPlayer类详解相关的知识,希望对你有一定的参考价值。 这是一个播放多媒体流的类 几个重要的枚举类型 enum QMediaPlayer::MediaStatus Defines the status of a media player"s current media. ConstantValueDescriptionQMediaPlayer::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 or PausedState.QMediaPlayer::BufferingMedia5The 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::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信号 void mediaStatusChanged(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信号 void positionChanged(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 void volumeChanged(int volume) 公有成员函数 QMediaPlayer(QObject * parent = 0, Flags flags = 0) ~QMediaPlayer()intbufferStatus() constQMediaContentcurrentMedia() constQNetworkConfigurationcurrentNetworkConfiguration() constqint64duration() constErrorerror() constQStringerrorString() constboolisAudioAvailable() constboolisMuted() constboolisSeekable() constboolisVideoAvailable() constQMediaContentmedia() constMediaStatusmediaStatus() constconst QIODevice *mediaStream() constqrealplaybackRate() constQMediaPlaylist *playlist() constqint64position() constvoidsetVideoOutput(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 playerStatestate() constintvolume() const 公有槽 voidpause()voidplay() 开始或重新开始播放当前媒体流voidsetMedia(const QMediaContent & media, QIODevice * stream = 0)voidsetMuted(bool muted)voidsetNetworkConfigurations(const QList & 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) 以上是关于Qt 之QMediaPlayer类详解的主要内容,如果未能解决你的问题,请参考以下文章 SQL怎么拼接字符串 EACCES Spawn Error Ionic 2 您可能还会对下面的文章感兴趣: 相关文章 浏览器打不开网址提示“ERR_CONNECTION_TIMED_OUT”错误代码的解决方法 如何安装ocx控件 VMware的虚拟机为啥ip地址老是自动变化 vbyone和EDP区别 linux/debian到底怎么重启和关机 苹果平板键盘被弄到上方去了,如何调回正常? 机器学习常用距离度量 如何查看kindle型号