【问题标题】:Playing the URL using MPMoviePlayerController使用 MPMoviePlayerController 播放 URL
【发布时间】:2011-10-19 05:59:10
【问题描述】:

我正在使用下面的代码在 iPhone 中播放本地电影文件Movie.m4v,使用 MPMoviePlayerController 并且工作正常。

现在我已将同一个文件放入我的在线服务器mobile.sample.com/Downloads/video/Movie.m4v。我想知道如何在 iPhone 中使用上述 URL 播放该电影(而不是使用 uiwebview)。

我怎样才能做到这一点?寻找你的想法。感谢您的帮助。


- (void) readyPlayer
{
    mp =  [[MPMoviePlayerController alloc] initWithContentURL:movieURL];

  if ([mp respondsToSelector:@selector(loadState)]) 
  {
    // Set movie player layout
    [mp setControlStyle:MPMovieControlStyleFullscreen];
    [mp setFullscreen:YES];

        // May help to reduce latency
        [mp prepareToPlay];

        // Register that the load state changed (movie is ready)
        [[NSNotificationCenter defaultCenter] addObserver:self 
                       selector:@selector(moviePlayerLoadStateChanged:) 
                       name:MPMoviePlayerLoadStateDidChangeNotification 
                       object:nil];
    }  
  else
  {
    // Register to receive a notification when the movie is in memory and ready to play.
    [[NSNotificationCenter defaultCenter] addObserver:self 
                         selector:@selector(moviePreloadDidFinish:) 
                         name:MPMoviePlayerContentPreloadDidFinishNotification 
                         object:nil];
  }
NSLog(@"ready");
  // Register to receive a notification when the movie has finished playing. 
  [[NSNotificationCenter defaultCenter] addObserver:self 
                        selector:@selector(moviePlayBackDidFinish:) 
                        name:MPMoviePlayerPlaybackDidFinishNotification 
                        object:nil];
}

【问题讨论】:

    标签: ios ios4 mpmovieplayercontroller


    【解决方案1】:

    查看在线观看或下载您无论如何都会消耗网络带宽的数据。如果您不使用UIWebView,则可以执行以下任一操作:

    1. http://allseeing-i.com/ASIHTTPRequest/How-to-use(基本处理 http 流)
    2. 在您的应用程序数据中下载电影,然后播放。放 您自己稍后删除它的逻辑。这样做的最大缺点是,如果 大尺寸的电影操作系统,那么您可能无法在您的应用程序中下载它 在 iOS 设备上获得有限的磁盘空间。

    【讨论】:

    • 感谢您的回复。只是为了我的学习,我想在我的 iphone 应用程序中播放一个在线网址...你能帮我吗
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-08
    • 2014-02-07
    • 1970-01-01
    相关资源
    最近更新 更多