Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPMoviePlayerController: Removing ±1sec black screen, when changing contentURL?

I'm working on an iPad project where i have to play short video files one after another smoothly. For playing the videos i'm using MPMoviePlayerController. The problem i'm facing is that when i call

[self.moviePlayer setContentURL:videoURL]

it does start the next video, but there is ±1 sec delay of black screen before it starts to play the next video (the videos are read from the disk, not streamed). I need to avoid this black screen as well as the delay.

So maybe some of you also experienced this problem and have some solutions? Thanks.

Btw, for now, as to at least avoid the black screen, I capture the last frame of the ending video, show it in a UIImageView, and remove it after 1 sec delay. But i'm hoping to find a more elegant fix.

like image 991
mt_ Avatar asked Nov 30 '10 13:11

mt_


2 Answers

The effect you are talking about is actually a combination of two problems: a black blink when you change the video (which doesn't happen upon assigning the video for the first time) and the delay before the controller starts playing video.

I'm currently screwed with the second one and don't know how to solve yet. As for the first one, just try to use another instance of MPMoviePlayerController. I mean when a video finishes playing (you can subscribe to a corresponding notification) just remove the old player, create a new one and put video there. This way you will avoid blinking, but there will be a delay (not sure, because of loading the video or because of player creation) before the next video starts playing.

Hope this helps a bit.

like image 62
Anton Avatar answered Oct 20 '22 08:10

Anton


Fond solution here http://joris.kluivers.nl/blog/2010/01/04/mpmovieplayercontroller-handle-with-care/ you need to use [self.moviePlayer prepareToPlay]; and catch MPMoviePlayerReadyForDisplayDidChangeNotification to use [self.moviePlayer play];

like image 41
user2557885 Avatar answered Oct 20 '22 07:10

user2557885