QPlaybackOptions Class

QPlaybackOptions 类可对媒体播放选项进行底层控制。更多

头文件: #include <QPlaybackOptions>
CMake.QPlaybackOptions find_package(Qt6 REQUIRED COMPONENTS Multimedia)
target_link_libraries(mytarget PRIVATE Qt6::Multimedia)
qmake: QT += multimedia
Qt 6.10
在 QML 中: playbackOptions

公共类型

(since 6.10) enum class PlaybackIntent { Playback, LowLatencyStreaming }

属性

公共功能

std::chrono::milliseconds networkTimeout() const
QPlaybackOptions::PlaybackIntent playbackIntent() const
qsizetype probeSize() const
void resetNetworkTimeout()
void resetPlaybackIntent()
void resetProbeSize()
void setNetworkTimeout(std::chrono::milliseconds timeout)
void setPlaybackIntent(QPlaybackOptions::PlaybackIntent intent)
void setProbeSize(qsizetype probeSizeBytes)

详细说明

QPlaybackOptions 提供媒体播放选项的底层控制。虽然我们强烈建议使用QMediaPlayer 的默认设置,但 QPlaybackOptions 可用于优化媒体播放,以适应默认选项并不理想的特定使用情况。

请注意,选项是对媒体后端的提示,如果当前媒体格式或编解码器不支持这些选项,则可能会被忽略。

播放选项依赖于媒体后端的支持。每个选项都记录了可用性。

另请参阅 QMediaPlayer

成员类型文档

[since 6.10] enum class QPlaybackOptions::PlaybackIntent

配置媒体播放意图,重点关注高质量播放或低延迟媒体流。

常数说明
QPlaybackOptions::PlaybackIntent::Playback0目标是稳健的高质量媒体播放,提供足够的缓冲以防止播放过程中出现故障。
QPlaybackOptions::PlaybackIntent::LowLatencyStreaming1减少缓冲可优化低延迟流媒体,但在播放过程中出现丢失帧或其他故障的可能性较高。

此枚举在 Qt 6.10 中引入。

属性文档

[since 6.10] networkTimeout : std::chrono::milliseconds

确定某些网络格式的套接字 I/O 操作所使用的网络超时。

该选项仅支持 FFmpeg 媒体后端。

此属性在 Qt 6.10 中引入。

访问函数:

std::chrono::milliseconds networkTimeout() const
void setNetworkTimeout(std::chrono::milliseconds timeout)
void resetNetworkTimeout()

[since 6.10] playbackIntent : PlaybackIntent

决定QMediaPlayer 应为稳健的高质量视频播放(默认)还是低延迟流进行优化。

此选项仅支持 FFmpeg 媒体后端。

此属性在 Qt 6.10 中引入。

访问函数:

QPlaybackOptions::PlaybackIntent playbackIntent() const
void setPlaybackIntent(QPlaybackOptions::PlaybackIntent intent)
void resetPlaybackIntent()

[since 6.10] probeSize : qsizetype

probesize 定义了在媒体播放开始前为收集流信息而分析的数据量(以字节为单位)。

探测值越大,播放效果越好,但可能会增加延迟。反之,较小的 probesize 值可以减少延迟,但可能会错过一些流细节。默认 probesize 为-1,实际 probesize 由媒体后端决定。

只有 FFmpeg 媒体后端支持该选项。

此属性在 Qt 6.10 中引入。

访问函数:

qsizetype probeSize() const
void setProbeSize(qsizetype probeSizeBytes)
void resetProbeSize()

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.