2014-11-08 54 views
0

我正在使用URL初始化一个新的MPMoviePlayerViewController,以播放来自服务器的全屏视频。播放器屏幕出现后,会出现“正在加载...”,但没有发生实际加载,由于某种原因导致没有网络通信。我用这个代码:MPMoviePlayer卡在“正在加载...”

- (IBAction)playerButtonPressed:(id)sender { 
    NSURL *url = [NSURL URLWithString: 
        @"http://ebookfrenzy.com/ios_book/movie/movie.mov"]; 

    MPMoviePlayerViewController *c = [[MPMoviePlayerViewController alloc] 
             initWithContentURL:url]; 

    [self presentMoviePlayerViewControllerAnimated:c]; 
} 

URL是正确的,这是我得到:
enter image description here

回答

1

您的代码工作完全在我的机器上。问题不可重现。

也许在你的情况下,某些东西阻止模拟器建立网络连接。它可能是LittleSnitch;网络可能关闭;有很多可能性。

您正在通过计算机的网络有效地挖掘模拟器的网络。我建议你在设备上而不是模拟器上运行代码,以避免这种复杂情况。

+0

谢谢!已经调试了这个代码大约30分钟,并且找不到任何错误!将调试网络堆栈... – 2014-11-08 19:40:52

+1

顺便说一句,如果你只能在iOS 8上运行,你应该从MPMoviePlayerViewController迁移并改用AVKit。 – matt 2014-11-08 19:42:08

+0

是的,我首先想到了这个想法,但是应用程序必须在iOS 7+上支持 – 2014-11-08 19:43:18