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];
}
精彩评论