2012-09-05 89 views
1

我嘗試從一個HTTP服務器以流的mp4-文件到我的iPhone與此代碼:iOS的電影流正常工作在模擬器,但不是在設備

- (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

我終於發現設備沒有問題,但與http服務器。它發送了錯誤的MIME類型(text/html而不是video/mp4),因此設備無法正確解釋它。所以我只需要將MIME類型添加到服務器,現在它就像一個魅力

相關問題