Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVPlayer Reverse Playback

How would one go about getting 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.

like image 918
fieldtensor Avatar asked May 23 '11 09:05

fieldtensor


1 Answers

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];
like image 155
Paresh Navadiya Avatar answered Oct 21 '22 13:10

Paresh Navadiya