Streaming Video using MPMoviePlayerController

Discussion in 'iOS Programming' started by Fontano, Jul 17, 2008.

  1. Fontano macrumors member

    Jun 27, 2008
    For the last week or so, I have been trying to get MPMoviePlayerController working with streaming video feeds...

    No luck.

    I am using the MoviePlayer sample as the base...
    And I have been working with the movieURL function, to change the source video.

    I have been successfully at access video outside of the package, on the local hard drive, and on network access drives... but not streaming to an HTTP or an RTSP.

    My latest attempt, was altering the line in movieURL (in MyViewController.m) to
    NSString *moviePath = @"";

    When the app plays, I get an on screen of:
    This Movie Could Not Be Played

    The Debug/Log reports:
    2008-07-17 10:20:12.194 MoviePlayer[4395:20b] ERROR! Please file a bug report!
    2008-07-17 10:20:12.195 MoviePlayer[4395:20b] Could not play the movie We received the AVController_ItemFailedToPlayNotification with info: Error Domain=NSOSStatusErrorDomain Code=-12783 UserInfo=0x1083d20 "This movie could not be played."

    Any ideas on how to go getting this to work?
  2. cwoloszynski macrumors member

    Jul 21, 2005
    Progress on this?

    Any chance you figured this out? I am seeing the same pop-up but I don't get the notification you do? Would you be willing to share the Notification registration code you used to get it?
  3. Fontano thread starter macrumors member

    Jun 27, 2008
    I was able to access Movies via HTTP progressive download.
    I have not returned to accessing a true streaming server, the files I have been able to access where complete video files on the server.

    IIRC, I posted this when I was having a problem with the player.
    Which ultimately ended up being an incompatibility issue with the DiVX codec/player being installed (The actual one from

    The other Problem I was having at the time, is that I didn't change the URL building to use a URL link instead of a local file.

    However, at the end of the work, it did work in the simulator, but not the device. And priorities have shifted, so I haven't returned to getting the streaming video to play.
  4. macrumors newbie

    Nov 5, 2008
    Hi Fontano

    Can you please explain how you achieved it? Are you saving the whole file locally and then playing it?
  5. CommanderData macrumors regular

    Dec 1, 2007
    Would you care to share code for what you've got so far? I think streaming video off a local network drive would be quite useful by itself... probably even more useful than internet streaming from HTTP. Especially when combined with the VPN access of the iPhone, where I could access many Gigabytes of my LAN content while traveling :)
  6. jnic macrumors 6502a

    Oct 24, 2008
    I'm not the original poster, but here's the code I'm using MPMoviePlayer to "stream" (progressive download) movies over HTTP. It's extremely simple:

    NSString *url = @"";
    MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:url]];
    [moviePlayer play];
    This often does not work in the simulator, but is always fine on the device. MPMoviePlayer does not appear to support RTSP.

    For local files, just substitute the remote URL for a local one:

    NSString *path = [bundle pathForResource:@"movie" ofType:@"mp4"];
    NSString *url = [NSURL fileURLWithPath:path];
  7. jnic macrumors 6502a

    Oct 24, 2008
  8. CommanderData macrumors regular

    Dec 1, 2007

    Hmmm. Am I missing something or are you suggesting local as in locally on the iPhone? What I want to do is use Wifi on the iPhone to access networked hard drives. Let's say I have a 2 Terabyte NAS on my local network that I want to access over Wifi from my iPhone for example (which I currently do from my laptop).

    If I take the MoviePlayer sample code, can I just supply it the network location like @"smb://NAS/media/videos/" or is it more complex than that?
  9. jnic macrumors 6502a

    Oct 24, 2008
    Yup, my misunderstanding.

    AFAIK, the movie player doesn't support Samba shares natively. You'd have to start an httpd to serve the videos, and set the URL to be its address on your local network (http://192.168..., etc.), or write your own Samba client to convert it on-the-fly.
  10. nikihana macrumors newbie

    Feb 6, 2009
    Sample, please


    Can you post the code fragment that actually plays a progressive download mp4 strea,?

    My app simple crashes when I try it :-(

    I am using the MoviePlayer sample as a base...

  11. iGrump macrumors newbie

    Feb 27, 2009
    If you're having trouble playing m4v etc from a web URL, make sure that the web server has the correct MIME types set up otherwise you will receive an error when trying to stream within iPhone app.

    You can check this by trying to view the movie directly in a web browser - if you get a 404/Page not Found error - this is likely to be MIME types.

Share This Page