How to change the speed of video playback

别来无恙 提交于 2019-12-17 19:57:07

问题


I'm wondering if it's possible to change the video playback speed in an iphone application. we want users to yell in the microphone to speed up the playback and get to the end.


回答1:


You have to use setCurrentPlaybackRate:




回答2:


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.




回答3:


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];              
}


来源:https://stackoverflow.com/questions/2483783/how-to-change-the-speed-of-video-playback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!