我尝试使用以下代码将 mp4 文件从 http 服务器流式传输到我的 iPhone:
- (IBAction)streamMovie:(id)sender
{
NSURL *url = [NSURL URLWithString:trailerPath];
if ([self.movieController respondsToSelector:@selector(setAllowsAirPlay:)])
[self.movieController.moviePlayer setAllowsAirPlay:YES];
[self.movieController.moviePlayer setContentURL:url];
[self presentMoviePlayerViewControllerAnimated:self.movieController];
[self.movieController.moviePlayer play];
}
这在模拟器上运行良好,但在我的 iPhone 设备(3GS 和 iOS 5.1)上根本不起作用。电影播放器只弹出然后立即消失。如果我再试一次,则会出现此日志条目:
An instance 0x1c5a20 of class AVPlayerItem was deallocated while key value observers
were still registered with it. Observation info was leaked, and may even become
mistakenly attached to some other object. Set a breakpoint on NSKVODeallocateBreak to
stop here in the debugger. Here's the current observation info:
我做错了什么,为什么这在模拟器上有效?