Sagar S. Kadookkunnan
Sagar S. Kadookkunnan

Reputation: 673

Is that possible to play a file that is currently downloading, using a MPMoviePlayerController?

I have a url for a video. I have started downloading that to the document directory of iOS device using ASIHTTPRequest. Before completing the download/during the downloading of that file, can I make a MPMoviePlayerController to start/play using that file. (I am not supposed to stream using MoviePlayer). I need to download and play simultaneously.

If anyone knows, please help through answers/comments.

Thank you in advance. :)

Upvotes: 0

Views: 1138

Answers (2)

Hitch22
Hitch22

Reputation: 365

From Apple's Streaming Media Guide (page 18):

"If your app delivers video over cellular networks, and the video exceeds either 10 minutes duration or 5 MB of data in a five minute period, you are required to use HTTP Live Streaming."

The great news is... Live Streaming is super easy. Much much easier than low level handling of streaming. You need access to the video & pass it though the Live Streaming tools.

Steps

  1. Download & install streaming tools from here: http://developer.apple.com/streaming/
  2. Open up terminal and type "mediafilesegmenter ~/PATH/TO/YOUR/VIDEO/FILE.m4v" (minus "")
  3. This will chop the video files into .ts segments and give you a .m3u8 playlist file
  4. Upload files to server or work locally to trial it out by turning on web sharing
  5. In a view, add iVar of MPMoviePlayerController, you'll need to link against the MediaPlayer.framework

Ej:

// self.player is an iVar of MPMoviePlayerController
MPMoviePlayerController *mp = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://path.to.playlist.file.m3u8"]];
self.player = mp;
[mp release];
[self.view addSubview:self.player.view];
[self.player prepareToPlay];
[self.player play];

Check out the man files that come with the streaming tools. There are a load of ways to customize the streaming stuff. But it's as easy as that to get streaming working on iOS.

Upvotes: 3

Max B.
Max B.

Reputation: 871

You may take a look at Matt Gallagher's Audiostreamer. He describes how to buffer audio and how to load the data over an NSURLConnection.

Matt Gallagher audiostreamer

Upvotes: 1

Related Questions