gpt4 book ai didi

ios - 如何在iOS中使用AVPlayer的函数 "setRate"

转载 作者:行者123 更新时间:2023-11-29 01:12:25 26 4
gpt4 key购买 nike

这是一个关于AVPlayer中setRate函数的API文档,我只是不明白这个函数的概念。

itemTime 和 hostClockTime?这些是什么?我什么时候需要它们?

您能给我一个使用这些参数的示例吗?

/*!
@method setRate:time:atHostTime:
@abstract Simultaneously sets the playback rate and the relationship between the current item's current time and host time.
@discussion You can use this function to synchronize playback with an external activity.

The current item's timebase is adjusted so that its time will be (or was) itemTime when host time is (or was) hostClockTime.
In other words: if hostClockTime is in the past, the timebase's time will be interpolated as though the timebase has been running at the requested rate since that time. If hostClockTime is in the future, the timebase will immediately start running at the requested rate from an earlier time so that it will reach the requested itemTime at the requested hostClockTime. (Note that the item's time will not jump backwards, but instead will sit at itemTime until the timebase reaches that time.)

Note that advanced rate control is not currently supported for HTTP Live Streaming.
@param itemTime The time to start playback from, specified precisely (i.e., with zero tolerance).
Pass kCMTimeInvalid to use the current item's current time.
@param hostClockTime
The host time at which to start playback.
If hostClockTime is specified, the player will not ensure that media data is loaded before the timebase starts moving.
If hostClockTime is kCMTimeInvalid, the rate and time will be set together, but without external synchronization;
a host time in the near future will be used, allowing some time for data media loading.
*/

最佳答案

如文档所述,您可以使用此函数将播放与外部事件同步。

这个问题在这里AVPlayer not synchronized用户(在他们的回答中)正在使用相同的功能来同步三个独立视频的播放(确保它们都以完全相同的速率播放并保持同步)。

您还可以调整速率以加快或减慢视频播放速度(例如“某种”慢动作)。

关于ios - 如何在iOS中使用AVPlayer的函数 "setRate",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35585360/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com