【问题标题】:Video player doesn't stop loading视频播放器不会停止加载
【发布时间】:2014-02-21 14:16:13
【问题描述】:

我正在开发一个应用程序,我想在其中播放来自远程 HTTP URL 的 mp4 视频。这是我的代码:

// Prepare URL
NSString *urlString = [NSString stringWithFormat:@"http://static.winterlightfilms.com/%@/film.mp4", responseObject];
NSLog(urlString);
NSURL *url = [NSURL URLWithString:urlString];

MPMoviePlayerController *moviePlayer=[[MPMoviePlayerController alloc] init];

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

moviePlayer.controlStyle=MPMovieControlStyleDefault;
moviePlayer.shouldAutoplay=NO;
[self.view addSubview:moviePlayer.view];
[moviePlayer setFullscreen:YES animated:YES];
[moviePlayer setContentURL:url];
moviePlayer.shouldAutoplay=YES;

我可以从 NSLog 行验证视频是否存在并且可以在网络浏览器上播放。但是,播放器永远显示“加载”轮。如何让视频播放?

【问题讨论】:

    标签: ios objective-c video


    【解决方案1】:

    这行得通:

    // Prepare URL
    NSString *urlString = [NSString stringWithFormat:@"http://static.winterlightfilms.com/%@/film.mp4", responseObject];
    NSLog(urlString);
    NSURL *url = [NSURL URLWithString:urlString];
    
    MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] init];
    mpvc.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
    [mpvc.moviePlayer setContentURL:url];
    
    [self presentMoviePlayerViewControllerAnimated:mpvc];
    

    【讨论】:

      猜你喜欢
      • 2015-03-04
      • 1970-01-01
      • 2013-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多