David Fauthoux
David Fauthoux

Reputation: 71

MPMoviePlayerController changing video speed

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

myMPMoviePlayerController.currentPlaybackRate = 2.f

doesn't change anything.

Upvotes: 5

Views: 3155

Answers (3)

swiftBoy
swiftBoy

Reputation: 35783

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.

Upvotes: 0

blackforestcowboy
blackforestcowboy

Reputation: 1021

You have to use the setCurrentPlaybackRate method, like this:

[myMPMoviePlayerController setCurrentPlaybackRate:2.f];

Upvotes: 4

Heath Borders
Heath Borders

Reputation: 32107

Play the movie first, then set the playback rate.

Upvotes: 12

Related Questions