开发者

AVPlayer Reverse Playback

开发者 https://www.devze.com 2023-03-08 04:18 出处:网络
How would one go about getti开发者_JAVA技巧ng an AVPlayer object to play its video content in reverse? The AVPlayerItem class has a property called \"reversePlaybackEndTime,\" which makes me think tha

How would one go about getti开发者_JAVA技巧ng an AVPlayer object to play its video content in reverse? The AVPlayerItem class has a property called "reversePlaybackEndTime," which makes me think that reverse playback is thus possible, but I can't seem to find anything in the docs about actually doing it.


You can reverse play like this as queuePlayer is AVPlayer:

Firstly get to end of video

CMTime durTime = self.queuePlayer.currentItem.asset.duration;
durationTime = CMTimeGetSeconds(durTime);
//NSLog(@"durationTime :%f : %f",durTime);
if (CMTIME_IS_VALID(durTime))
    [self.queuePlayer seekToTime:durTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero];
else
    NSLog(@"In valid time");

Now set Rate of AVPlayer to negative value

[self.queuePlayer setRate:-1];


When you send 'play' message to the AVPlayer object it starts playing and this is equivalent to setting the rate property to 1.0. Have you tried to set that property to -1.0? I haven't Mac at the moment to test it, so if this doesn't work I'll remove my answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消