Why does my MPMoviePlayerController suddenly change load state to unknown? - iphone

My app is a digital magazine consisting of many pages. Some pages have video embedded in them.
I am using MPMoviePlayerViewController for the video playback.
The problem is that once I get to any page where the next page also contains a video then the video appears briefly then blanks out.
I've switched out video files, so I know it isn't the files themselves.
When the page loads offscreen ready to be scrolled into view the load state changes to 3 = MPMovieLoadStatePlayable + MPMovieLoadStatePlaythroughOK (all good). Then when a second MPMoviePlayerController is loaded, the load state of the original suddenly changes to 0 (MPMovieLoadStateUnknown).
In the docs for MPMoviePlayerController it says
Note: Although you can create multiple
MPMoviePlayerController objects and
present their views in your interface,
only one movie player at a time can
play its movie.
I read this to mean I can't play more than one at a time but does this it also mean I can't even load up more than one movie at a time?

It turns out you can't even load more than one MPMoviePlayerController at a time. You can create the object but if you supply a URL to more than one then one will get unloaded.

Related

add more than 1 video player in iphone

Is there any way to add more than 1 video player in a single View? I am getting the .m4v list from server adn have to display that much videos in single page.
It doesnot matter if I play 1 video at a time but which ever video I want must play there itself.
So the videos are placed one below other.
I have tried using mpmoviecontroller but it's drawback is it can have only one instance in the whole applicaiton So if i try to alloc 2 players in a view then the first one does not work and only one player works..
Is there any legal alternate way for the same?
MPMoviePlayerController will allow multiple instances, but only one of them can be playing their movie at any given time.
Please check the link : http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPMoviePlayerController_Class/MPMoviePlayerController/MPMoviePlayerController.html
I used AVPlayer class (which also MPMoviePlayerController uses under the hood) to successfully play multiple videos from multiple source.
The process of using it is more involved than MPMoviePlayerController, but I would say it is definitely worth to look at if you want some customized behavior in your player. The official programming guide is a good start.

Playing the multiple Audio files in different Views using single audio player instance in iphone,

I am new to audio playing, I am having one issue regarding Audio playing .The issue is Playing the multiple audio files , and controlling the current playing audio file from other Views.
My Requirement is. In my app i am having 4 audio files in different Views. Once the audio play button is clicked in some View, The audio playing has to be started and pause and stop and slider buttons has to be displayed , Even i navigated to the next view the audio has to be continued (I should be able to control the currently playing audio), If i pressed the navigated view's audio, The previous audio has to be stopped, Navigated page audio has to be played. After completion of Navigated page Audio, the resumed audio of Previous page has to be played.
As of my knowledge, I have take single audio instance in AppDelegate. I am referring that Audioplayer instance in all view's , Where ever i need. It is not working.(some times giving error , some times unable to stop the Previous Audio playing).
Thanks in advance.
if i am not wrong you have defined the audioplayer in appdelegate, right?
and which class are you using for this , avplayer , avaudioplayer or mpplayer ?
and by the way , if we come to answer of mine,
i have used avplayer and avaudioplayer for this kind of business and it worked without problem , have you checked that in everyview you initialize you appdelegate instance? if not please check this and
also in your plist file , you should state that app will play audio in background to get the support for that.
hope this answer will help! :)

Is it possible to play a video on iPhone and have a subtitles synchronized with it show up?

I want to add a "subtitles" to a video played in an iPhone app. I don't want those subtitles encoded into the video itself - ideally I'd love to have a view showing the video (with pause, play, volume and such standard controls) together with a view displaying the text that changes together with movie time changing.
If I drawn that, it's something like this,
So, basicly, I would need a way to get a method called when movie is playing, and then synchronize the text displayed on the label with the movie timing.
Anyone used a solution that was able to do it?
I've recently done something that syncs graphics to times in an audio track. The way I did it was by using the currentPlaybackTime property of the MPMediaPlayback interface (which the MoviePlayer controller should also conform to). This returns the seconds elapsed in the media, in a double (typedef'ed as NSTimeInterval). The actual synchronisation in my app was not done in notifications, as I couldn't find any resembling a "tick", but instead I created a timer, calling a function queried the currentPlaybackTime, and updated the graphics based on this.
In terms of your implementation, I would assume you have some kind of system for associating label text (subtitles) with a particular time. You could then compare the text's time range with the time returned from currentPlaybackTime to find the correct text to display.

Play a video whose URL is not known in advance - without reload - without extra tab

I have lots of buttons on a web page. Depending on which one is clicked, I want to play a different video.
A large number of <video> elements doesn't seem to work particularly quickly or reliably.
So far, I have tried to:
Create and play() the video element dynamically, after an image is clicked:
var video = document.createElement('video');
video.src = 'video.mp4';
document.body.appendChild(video.play);
video.play();
This works on iOS 4, but not on iOS 3.
Create the video element before, and just change the src.
Doesn't work either.
It seems like the video object must have already done "it's thing", before it can be played.
Use window.open() to open the video URL.
This will cause an annoying new tab to open, which will remain open after playback has completed.
Set window.location
This will cause the current page to be reloaded after playback has completed, which I'm trying to avoid.
Any more ideas?

iPhone media player framework : play multiple movie files seamlessly

I am using the media player framework's MPMoviePlayerController to play local (on device) m4v files. Depending on user's selection, I want to be able to play multiple movies one after the other seamlessly.
To do this, I queue up the movies in an array and in my observer method that is called on the MPMoviePlayerPlaybackDidFinishNotification event which is triggered after one movie finishes, I play the next movie in the queue.
However, this is far from seamless. After each movie finishes, the iphone view transitions back to the base view from which the movieplayer was called and then picks up the movie called in the observer method (moviePlayBackDidFinish).
Is there a way to make the movies play one after the other seamlessly without breaking to transition back to the base view?
Just to be very clear, all the movies are local and bundled with the app as resources, not being streamed from anywhere.
You can use AVMutableComposition. It combines media data from multiple file-based sources in a custom temporal arrangement, in order to present or process media data from multiple sources together.