以2x 3x 4x速度播放/转发video – iPhone SDK

我想以不同的速度在MPMoviePlayerController中播放/转发video。 任何人都可以build议我怎么做到这一点。

现在我正在快进(单速),但在几秒钟内它恢复正常速度。

请build议。

MPMoviePlayerController Conforms to MPMediaPlayback protocol you can see the property currentPlaybackRate as :- @property(nonatomic) float currentPlaybackRate A value of 0 represents that the video is stopped , a value of 1 indicates normal speed and further positive values indicate increased speed while negative ones indicate reverse . 

同时检查你的endseeking委托方法的MPMediaPlayback,因为它是唯一的方法,恢复回放正常

这里是一个代码转发和后退电影作为2x 3x 4倍速度为MPMoviePlayerViewController

在.h文件中

 @property(nonatomic) float currentPlaybackRate; 

在.m文件中

 - (void)viewDidLoad { currentPlaybackRate=1.0; //video Play in Normal speed } 

现在在FastForward和FastBackwardbutton操作

 [fastForward addTarget:self action:@selector(fastForward) forControlEvents:UIControlEventTouchUpInside]; [fastBackWard addTarget:self action:@selector(fastBackward) forControlEvents:UIControlEventTouchUpInside]; 

行动代码

 -(void)fastForward { [mp.moviePlayer pause]; playPauseButton.selected=TRUE; if (currentPlaybackRate < 0.0) { currentPlaybackRate = 1.0; } if (currentPlaybackRate < 4.0) { currentPlaybackRate=currentPlaybackRate+1.0; NSLog(@"Forward::%f",currentPlaybackRate); mp.moviePlayer.currentPlaybackRate=currentPlaybackRate; } } -(void)fastBackward { [mp.moviePlayer pause]; playPauseButton.selected=TRUE; if (currentPlaybackRate > 0.0) { currentPlaybackRate = 0.0; } if (currentPlaybackRate > -4.0) { currentPlaybackRate=currentPlaybackRate-1.0; NSLog(@"BackWard::%f",currentPlaybackRate); mp.moviePlayer.currentPlaybackRate=currentPlaybackRate; } }