MPMoviePlayerController在線播放問題

蘋果發布iOS 9系統之后已經棄用MPMoviePlayerController,在此討論并無多大意義,但是我們的項目目前還沒有遷移到AVKit框架,為了兼容iOS 7和iOS 8,仍然使用MPMoviePlayerController播放視頻。在此對遇到的問題做一個記錄:

1、在線播放視頻崩潰問題

播放在線視頻時出現概率崩潰,堆棧信息如下:

在stack overflow上找到問題的解決辦法,鏈接在此

官方文檔中關于movieSourceType的描述:
The default value of this property is MPMovieSourceTypeUnknown
. This property provides a clue to the playback system as to how it should download and buffer the movie content. If you know the source type of the movie, setting the value of this property before playback begins can improve the load times for the movie content. If you do not set the source type explicitly before playback, the movie player controller must gather this information, which might delay playback.
崩潰代碼中未設置movieSourceType,個人推測可能是因為當播放器從網絡加載視頻的時候,因為網絡原因數據傳輸不完成,播放器將movieSourceType推測為某一種類型,而當開始播放時,視頻流卻并不是播放器先前推測的類型,于是出現崩潰。

2、視頻不顯示,聲音繼續播放的問題

放播放器的方向為UIInterfaceOrientationMaskLandscape,從播放器界面彈出方向為UIInterfaceOrientationMaskPortrait的視圖控制器,再從該視圖控制器返回播放界面后,播放器視頻不顯示,但聲音可以繼續
由于屏幕方向旋轉會引起播放器視圖重新布局,當回到播放器之后,需要重新設置moviePlayer.view的Frame。

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容