以 2x 3x 4x 速度播放/转发视频 - iPhone SDK



我想在MPMoviePlayerController中以不同的速度播放/转发视频。任何人都可以建议我如何做到这一点。

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

请指教。

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 .

还要检查 MPMediaPlayback 的寻端委托方法,因为它是唯一将播放恢复为正常的方法

这是将前进和后退电影作为 MPMoviePlayerViewController 的 2x 3x 4x 速度的代码

在 .h 文件中

@property(nonatomic) float currentPlaybackRate;

在 .m 文件中

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

现在在快进和快退按钮操作

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

最新更新