MPMoviePlayerController改变视频速度

时间:2011-01-04 12:46:55

标签: ios video mpmovieplayercontroller

有没有办法使用MPMoviePlayerController以双倍速度播放视频?

myMPMoviePlayerController.currentPlaybackRate = 2.f

不会改变任何事情。

3 个答案:

答案 0 :(得分:12)

先播放电影,然后设置播放速率。

答案 1 :(得分:4)

您必须使用setCurrentPlaybackRate方法,如下所示:

[myMPMoviePlayerController setCurrentPlaybackRate:2.f];

答案 2 :(得分:0)

现在即使它有点老问题,但如果有人遇到同样问题,我想分享一下。

以下是我正在使用的代码示例以及与我合作

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];

    [self dismissViewControllerAnimated:YES completion:^{

    if (CFStringCompare ((__bridge_retained CFStringRef)mediaType, kUTTypeMovie, 0) == kCFCompareEqualTo) {

        MPMoviePlayerViewController *theMovie = [[MPMoviePlayerViewController alloc]
                                                 initWithContentURL:[info objectForKey:UIImagePickerControllerMediaURL]];
        [theMovie.moviePlayer play];
        theMovie.moviePlayer.currentPlaybackRate = 2.00f;//here we can set speed
        theMovie.moviePlayer.fullscreen = YES;

        [self presentMoviePlayerViewControllerAnimated:theMovie];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMovieFinishedCallback:)
                                                     name:MPMoviePlayerPlaybackDidFinishNotification object:theMovie];
    }
    }];
}

希望这会对某人有所帮助。