簡體   English   中英

從HTTP服務器的iOS電影流正常工作在模擬器,但不是在裝置

[英]iOS movie stream from http server works fine on simulator, but not on device

我嘗試使用以下代碼將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:

我在做什么錯?為什么在模擬器上可以正常工作?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM