Reverse video playback in iOS

前端 未结 2 729
一向
一向 2020-12-16 18:33

I want to play video backward in AVPlayer. I have tried with changing rates property to -1.0, and although it did work it was not smooth. Is there any way through which I ca

2条回答
  •  一个人的身影
    2020-12-16 19:07

    You have to reach at the end of the current item and then set the rate to the negative value. Something like this:

    -(void)reversePlay { CMTime durTime = myPlayer.currentItem.asset.duration; if (CMTIME_IS_VALID(durTime)) { [myPlayer seekToTime:durTime toleranceBefore:kCMTimeZero toleranceAfter:kCMTimeZero]; [myPlayer setRate:-1.0]; } else NSLog(@"Invalid time"); }

    source: https://stackoverflow.com/a/16104363/701043

提交回复
热议问题