1

我尝试使用以下代码将 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:

我做错了什么,为什么这在模拟器上有效?

4

1 回答 1

0

我终于发现设备没有问题,但是http服务器有问题。它发送了错误的 MIME 类型(文本/html 而不是视频/mp4),因此设备无法正确解释它。所以我只需将 MIME 类型添加到服务器,现在它就像一个魅力

于 2012-09-06T08:53:34.783 回答