Search code examples
ios4

MPMoviePlayerController causes flash of black at start of video


The movie plays just fine but there is a quick black flash right before it plays. Is this a quirk resulting from setting the controlstyle to MPMovieControlStyleNone?

NSString *url = [[NSBundle mainBundle] pathForResource:@"00" ofType:@"mov"];
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] 
    initWithContentURL:[NSURL fileURLWithPath:url]];

[[NSNotificationCenter defaultCenter]
    addObserver:self
    selector:@selector(movieFinishedCallback:)
    name:MPMoviePlayerPlaybackDidFinishNotification
    object:player];

//---play video in implicit size---
player.view.frame = CGRectMake(80, 64, 163, 246);
[self.view addSubview:player.view];

// Hide video controls
player.controlStyle =  MPMovieControlStyleNone;

//---play movie---
[player play];

Solution

  • Evidently there is a flash of black in the movie rect until enough movie loads so it can start playback. Here is my workaround:

    1. Create a UIImageView and put the MPMoviePlayerController in it. That way you can set the alpha to 0.

    2. As soon as you call [player play]; to play the video, set up a .5 second timer.

    3. When the time is done, change the alpha to 1.

    This will make the player invisible for 1/2 second (which hides the black flash).