Hi using MPMoviePlayerController to stream video into the app. However, it takes a long time to load and I want to be able to pre-buffer the video. Any suggestions?
-
Anything below 8 seconds can be considered normal - are you within that range? To cut those 8 seconds short, check my answer on point 1. - in short; prepare to play before the user actually hits the play button. – Till Jul 01 '11 at 18:40
1 Answers
Use
[MPMoviePlayerControllerInstance prepareToPlay]
as soon as you know that the user might start playback of a movie. You might also want setMPMoviePlayeController.autoPlay
to something that fits best, depending on your application.From Apple's Documentation;
This method is called automatically when you call the play method. Calling it before you call play gives the receiver a chance to prepare items sooner and may result in decreased latency when starting playback. However, calling this method may also interrupt any active audio sessions.
Make sure your HTTP stream contains a low bandwidth alternative using less than 64Kbps (audio and video combined). Note that the
MPMoviePlayerController
usually starts buffering the low rate playback index profile before raising the bar and attempting to load higher bandwidth profiles. It will be prepared to play once it has a few seconds worth of movie data.Use the
MPMoviePlayerController.movieSourceType
property when initializing your player to cut down the media recognition delay.From the MPMoviePlayerController Class Reference:
The default value of this property is MPMovieSourceTypeUnknown. This property provides a clue to the playback system as to how it should download and buffer the movie content. If you know the source type of the movie, setting the value of this property before playback begins can improve the load times for the movie content. If you do not set the source type explicitly before playback, the movie player controller must gather this information, which might delay playback.

- 3,012
- 4
- 38
- 50

- 27,559
- 13
- 88
- 122
-
Thanks i have tried that and its not really improved it. Also would i need to use //playerViewController.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming; – user421704 Jul 02 '11 at 13:05
-
Ive also notice everytime i use player.movieSourceType = MPMovieSourceTypeStreaming; – user421704 Jul 02 '11 at 13:13
-
it just states loading and does not load the video...this is very frustrating as all i would like to do is present the standard video loader to the user whilst its buffering...any further suggestions. Also as I am fairly new to xcode am i using the right class to "stream" video... – user421704 Jul 02 '11 at 13:15
-
Are you actually using an HTTP-Stream? It sounds to me as if you were using progressive download instead. Is the file-extension m3u8 or mp4? – Till Jul 02 '11 at 14:13
-
Good point to suggest the mediatype to the player, adding that to my list of suggestions. – Till Jul 02 '11 at 14:14
-
hi using http-stream now. I am nearly up and running but now getting a few errors when using the validating tool: – user421704 Jul 02 '11 at 19:56
-
WARNING: Playlist Content-Type is 'text/plain', but should be one of 'application/x-mpegurl', 'application/vnd.apple.mpegurl', 'audio/x-mpegurl' or 'audio/mpegurl'. – user421704 Jul 02 '11 at 19:56
-
-
i am assuming the manifest is what i point to in my app which will detect the bandwidth, thanks for your help so far – user421704 Jul 02 '11 at 22:01
-
You should search right here on SO for help on that matter. When getting stuck, try posting a new question. If my answers helped, please upvote and accept. See this for more on creating HTTP-streams compatible with iOS devices: http://stackoverflow.com/questions/3209243/iphone-http-streaming-m3u8-and-ts-files-how-to-create-using-ffmpeg – Till Jul 03 '11 at 01:55
-
Just a small correction since the IDE doesn't recognize: "autoPlay", you should try: 'shouldAutoplay' ;) – polyclick Oct 04 '12 at 13:04