开发者

How to change the speed of video playback

开发者 https://www.devze.com 2022-12-23 19:41 出处:网络
I\'m wondering if it\'s possible to change the video playback speed in开发者_Python百科 an iphone application. we want users to yell in the microphone to speed up the playback and get to the end.You h

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


You have to use setCurrentPlaybackRate:


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.


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

精彩评论

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