How to change the speed of video playback

对着背影说爱祢 提交于 2019-11-28 11:45:19

You have to use setCurrentPlaybackRate:

Jean Fabre

There is a rate property for the AVPlayer.

If you take the example from Apple called "avPlayerDemo" in the resource section, you then simply have to set the mplayer.rate. It worked for me, I created a new slider in the xib files, implemented that slider in the AVPlayerDemoPlaybackViewController and simply set mPlayer.rate to the slider value.

HiDuEi

What about the MPMoviePlayerController?

setCurrentPlaybackRate 

Here's some code which does not work at that spot

-(IBAction)abspielen:(id)sender 
{
    NSString *titleOfButton = [sender titleForState:UIControlStateNormal];
    NSBundle *bundle = [NSBundle mainBundle];
    NSString *moviePath = [bundle pathForResource:titleOfButton ofType:@"mov"];
    NSURL *movieURL = [ NSURL fileURLWithPath:moviePath];

    MPMoviePlayerController *themovie = [[MPMoviePlayerController alloc]initWithContentURL: movieURL];  
    [themovie play];
    [themovie setCurrentPlaybackRate:2.f];    
    [themovie release];

    MPMoviePlayerViewController *moviePlayer = [[MPMoviePlayerViewController alloc] initWithContentURL:movieURL];
    [self presentMoviePlayerViewControllerAnimated:moviePlayer];
    [moviePlayer release];              
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!