MPMoviePlayerController changing video speed

青春壹個敷衍的年華 提交于 2019-12-06 03:57:15

问题


Is there a way to play video at double speed using MPMoviePlayerController?

myMPMoviePlayerController.currentPlaybackRate = 2.f

doesn't change anything.


回答1:


Play the movie first, then set the playback rate.




回答2:


You have to use the setCurrentPlaybackRate method, like this:

[myMPMoviePlayerController setCurrentPlaybackRate:2.f];



回答3:


Even it's bit old question now but I would like to share if someone having same problem.

Here is the code sample I am using and its working with me

-(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];
    }
    }];
}

Hope this will help someone.



来源:https://stackoverflow.com/questions/4593733/mpmovieplayercontroller-changing-video-speed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!