我尝试使用以下代码将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设备(带有iOS 5.1的3GS)上根本不起作用。电影播放器只会弹出然后立即消失。如果我再试一次,则会显示此日志条目:
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:
我做错了什么,为什么这会在模拟器上运行?
答案 0 :(得分:0)
我终于发现该设备没有问题,但使用了http服务器。它发送了错误的MIME类型(text / html而不是video / mp4),因此设备无法正确解释它。所以我只需要将MIME类型添加到服务器,现在它就像魅力一样