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

时间:2012-05-09 10:23:14

标签: iphone ios mpmovieplayercontroller

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

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

请建议。

2 个答案:

答案 0 :(得分:4)

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的终端委托方法,因为这是将播放恢复正常的唯一方法

答案 1 :(得分:0)

以下为MPMoviePlayerViewController的前向和后向电影代码为2x 3x 4x速度

在.h文件中

@property(nonatomic) float currentPlaybackRate;

在.m文件中

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

现在开启FastForward和FastBackward按钮操作

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