Load MPMoviePlayer Without playing video. Just preview

134 Views Asked by At

I am playing a m4v video in my app. It is playing fine but i just want to load the video without playing it. Just the preview.

I am using following code.

-(void)test
{
    self.player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:@"YOUR_PATH"]];
    //[self.player prepareToPlay];
    [self.player setControlStyle:MPMovieControlStyleDefault];
    [self.player.view setFrame: self.view.bounds];  // player's frame must match parent's
    [self.view addSubview: self.player.view];

}

But If i am uncommenting [self.player prepareToPlay];, It is starting to play.

If I comment [self.player prepareToPlay];, video is not loading.

1

There are 1 best solutions below

0
On BEST ANSWER

try this

-(void)test
{
    self.player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:@"YOUR_PATH"]];
    [self.player prepareToPlay];
    [self.player play];
    [self performSelector:@selector(pausePlayer) withObject:nil afterDelay:0.1];
    [self.player setControlStyle:MPMovieControlStyleDefault];
    [self.player.view setFrame: self.view.bounds];  // player's frame must match parent's
    [self.view addSubview: self.player.view];

}
-(void)pausePlayer
{
    if (self.player)
    {
        [self.player pause];
    }
}