2012-08-16 165 views
1

立即解僱本身我提出了一個MPMovieViewController用下面的代碼:MPMoviePlayerViewController在iOS 4.2的

NSString *path = [[NSBundle mainBundle] pathForResource:@"Tutorial" ofType:@"m4v"]; 

// If path is NULL (the resource does not exist) return to avoid crash 
if (path == NULL) 
    return; 

NSURL *url = [NSURL fileURLWithPath:path]; 

MPMoviePlayerViewController *mpViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:url]; 
mpViewController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen; 
mpViewController.moviePlayer.shouldAutoplay = YES; 

// NOTE: This can crash the app in the Simulator. This is a known bug 
// in xcode: http://stackoverflow.com/a/8317546/472344 
[self presentMoviePlayerViewControllerAnimated:mpViewController]; 

這工作正常的iOS 4.3及以上,但我已經有人對其進行測試運行iOS 4.2的設備上。 1和電影播放器​​視圖控制器呈現,但立即自行解散。我無法在文檔中找到任何可以解釋這一點的內容。有沒有人有任何想法?

回答

1

這聽起來很像電影內容本身的不兼容性。

我懷疑iOS 4.2.1設備是iPhone 3G。 3G不支持最新型號的編解碼器。

iOS4.2.1(及以下版本)中的iPhone 3G不支持主配置文件,但僅支持基準配置文件。

長話短說,您試圖播放的視頻與設備不兼容,您需要使用H264的基線配置文件重新編碼它們。

下面是由Apple完成的兼容性與編碼矩陣。即使這被稱爲HTTP流式編碼建議,它仍然適用於非流式傳輸(漸進式下載)和本地播放。

enter image description here

+0

謝謝,我開始懷疑同樣的事情。有趣的是,它可以在運行iOS 4.2.1的iPod 2G上運行。我會嘗試使用編碼進行測試。 – Darren 2012-08-16 22:44:17

+0

如果您的內容可通過網絡訪問,請嘗試直接從您的移動Safari瀏覽器播放。這將排除您的代碼的任何問題並確認編碼問題。 – Till 2012-08-16 22:54:15

+0

是的,事實證明這是問題所在。 – Darren 2012-08-17 02:08:55