Buffer, switch and loop playback of videos within an iPhone application to simulate a non-stop video feeds
I am not an iPhone developer (yet). So please excuse me if this issue is very basic question.
From what I can gather from the development documentation, it is only possible to 'play' one video file at a time.
The requirement I have is to switch from 1 video to another seamlessly or switch to a 2nd instance of the first video and keep 'looping'.
Is it possible to load/buffer a 2nd video so that videos can be seamlessly played after each other to g开发者_运维技巧ive the effect that there is a constant video feed? Or, 'playing' 2 videos but only having one on screen at any one time?
Unfortunately (and much to my disgust) you cannot make a seamless loop. There is however a MPMoviePlayerPlaybackDidFinishNotification notification/event that you can observe/listen to which essentially gives you an event when the movie has finished playing. You can use this to play the next video or repeat the one you just played.
The down side is that the MPMoviePlayerController fades the previous movie out (to the background color) when it has finished playing which stops us from looping continuously. If your video does not have sound, I would suggest extracting the frames and playing them back with a UIImageView, if it does have audio, then (like me) you are kind of stuck!
Good luck.
You can loop a video with iOS 3.2+ on iPad. To compile for iPhone I had to use a base SDK of 4.1 (4.0 should work as well)
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:nsUrl];
moviePlayer.repeatMode = MPMovieRepeatModeOne;
[mp play];
This article helped me set things up: http://iosdevelopertips.com/video/getting-mpmovieplayercontroller-to-cooperate-with-ios4-3-2-ipad-and-earlier-versions-of-iphone-sdk.html
As of IPhone SDK 3.1.3 the MPMoviePlayer cannot do this. Keep an eye out for future SDK updates.
精彩评论