Question

I have an MPMoviePlayerController which takes a link and plays the video off the link. Using WiFi this presents no problem, video is played and all is well.

Using 3G network however, it hangs for a few seconds before throwing MPMoviePlayerPlaybackDidFinishNotification, which a localised description of 'The operation could not be completed'.

My code is as follows:

    videoPlayerController =  [[MPMoviePlayerController alloc]
                 initWithContentURL:url];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlayBackDidFinish:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:videoPlayerController];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(willEnterFullscreen:)
                                             name:MPMoviePlayerWillEnterFullscreenNotification
                                           object:videoPlayerController];

    videoPlayerController.controlStyle = MPMovieControlStyleDefault;
    videoPlayerController.shouldAutoplay = YES;
    videoPlayerController.repeatMode = MPMovieRepeatModeOne;

    CGRect rect = _documentViewer.frame;
    [videoPlayerController.view setFrame:rect];
    [self.scroller addSubview:videoPlayerController.view];
    [videoPlayerController setFullscreen:NO animated:YES];

As I mentioned, it works fine using a WiFi connection, just doesn't like doing the same over 3G. The video itself is 26.8 MB off a specific URL. Does 3G limit the amount you can download at once on the IOS? Is there an alternative to play back videos over 3G networks?

Thank you for your time!

Was it helpful?

Solution

To serve a video file over a slow network, you should be using HTTP Live Streaming (HLS).

Your code need not change, however the URL you call it with should point to the stream's index file. The index file amounts to a playlist of individual (often 10 second) MPEG Transport Stream files.

Explore the details on Apple's HTTP Live Streaming page, or get an overview and list of server software at Wikipedia.

As an aside, you don't show the declaration of videoPlayerController, but you need to make sure that it's a property of your view-controller, or in some way make sure that its lifetime is going to be as long as the video is being played for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top