QPlaybackOptions Class
QPlaybackOptions 类允许对媒体播放选项进行底层控制。更多内容...
| 头文件: | #include <QPlaybackOptions> |
| CMake: | 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 } |
属性
(since 6.10)networkTimeout : std::chrono::milliseconds(since 6.10)playbackIntent : PlaybackIntent(since 6.10)probeSize : qsizetype
公共函数
| QPlaybackOptions(QPlaybackOptions &&) | |
| 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::Playback | 0 | 该意图旨在实现稳健且高质量的媒体播放,提供足够的缓冲以防止播放过程中出现卡顿。 |
QPlaybackOptions::PlaybackIntent::LowLatencyStreaming | 1 | 缓冲量被减少以优化低延迟流媒体传输,但播放过程中出现丢帧或其他卡顿现象的可能性较高。 |
此枚举类型在 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 定义了在媒体播放开始前,为收集流信息而需要分析的数据量(以字节为单位)。
较大的探测大小值可以提供更稳定的播放效果,但可能会增加延迟。相反,较小的探测大小值可以降低延迟,但可能会遗漏一些流的细节。默认探测大小为 -1,实际探测大小由媒体后端决定。
此选项仅在 FFmpeg 媒体后端中受支持。
此枚举类型在 Qt 6.10 中引入。
访问函数:
| qsizetype | probeSize() const |
| void | setProbeSize(qsizetype probeSizeBytes) |
| void | resetProbeSize() |
成员函数文档
[constexpr noexcept default] QPlaybackOptions::QPlaybackOptions(QPlaybackOptions &&)
通过Move构造一个QPlaybackOptions 的实例。
© 2026 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.