MPMoviePlayerController and HTTP Live Streaming

后端 未结 4 519
执念已碎
执念已碎 2020-12-14 11:26

every one. I\'m trying to figure out how to play live stream using MPMoviePlayerController. For testing i\'m using Apples test stream sample http://devimages.apple.com/iphon

相关标签:
4条回答
  • 2020-12-14 12:04

    Your problem is probably with the URL. MPMoviePlayerController wants the URL directly to the file you want to play. You are providing the URL for an HTML page which the movie player doesn't understand. That is why it does work in UIWebView since a web browser understands HTML. If you want more information about what's wrong you can check the error doing the following, quoted from Apple's documentation:

    To check for errors in URL loading, register for the MPMoviePlayerContentPreloadDidFinishNotification or MPMoviePlayerPlaybackDidFinishNotification notifications. On error, these notifications contain an NSError object available using the @"error" key in the notification’s userInfo dictionary.

    It would look something like:

    - (void) moviePlayBackDidFinish:(NSNotification*)notification {
        NSError *error = [[notification userInfo] objectForKey:@"error"];
        if (error) {
            NSLog(@"Did finish with error: %@", error);
        }
    }
    

    If you want to try and play that sample you can try and access the URL for the stream directly, which would be: http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

    0 讨论(0)
  • 2020-12-14 12:14

    @Andrew:

    Here is Apple documentation of HTTP Live Streaming including sample code http://developer.apple.com/library/ios/search/index.php?Search=HTTP+Live+Streaming+Overview

    Dung.

    0 讨论(0)
  • 2020-12-14 12:16

    You should use direct link to play list file: http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8

    NSURL *mediaURL = [NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
    MPMoviePlayerController *mediaPlayer = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
    
    0 讨论(0)
  • 2020-12-14 12:19

    Try object:mp instead of object:nil in your NSNotification

    0 讨论(0)
提交回复
热议问题