Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading MPMoviePlayerViewController with transparent background?

i´ve added a MPMoviePlayerViewController instance and playing of a movie works great. I´ve 3 buttons and want to load different videos in a UIView-container. That works, too. But if i click on a button to load an other video, everytime the background is flickering black. I´ve set the color to "clearColor":

    player.moviePlayer.backgroundView.backgroundColor = [UIColor  clearColor];

But that doesn´t help. Is there a way to load a video without a background - only the video-content?

Thanks for your time.

like image 360
geforce Avatar asked Jul 07 '10 12:07

geforce


2 Answers

  1. Not sure about the flickering issue. You said it flickers when you load another video -- Are you unintentionally layering multiple videos on top of each other? Make sure you remove the old one!
  2. The black background likely is because your MPMoviePlayerController's scalingMode property is set to MPMovieScalingModeAspectFit (Apple's Documentation: MPMoviePlayerController scalingMode)

For issue #2, like you, I had expected setting the backgroundView's color to handle this, however it seems there is another view behind that which you also need to set the backgroundColor to clearColor. My hack for this was to simply iterate through the movie player's subviews and set their backgroundColor to clear.

Hack/"Solution" example using your variable name:

for(UIView* subV in player.moviePlayer.view.subviews) {
    subV.backgroundColor = [UIColor clearColor];
}

You have to re-apply clearColor to the subviews any time you enter/exit fullscreen mode as well. I hope someone else has a better solution because this method seems pretty kludgy.

like image 93
MechEthan Avatar answered Oct 18 '22 20:10

MechEthan


another option is to hide the video player and then show it when it is ready to display

caveat needs IO6>= i believe:

https://stackoverflow.com/a/19459855/401896

like image 38
yeahdixon Avatar answered Oct 18 '22 19:10

yeahdixon