2012-05-31 24 views
6

我有一個處理流式視頻的應用程序。用.m3u8播放列表開始,它創建AVAssets數組,並通過AVPlayer不能在漸進式下載和流媒體之間切換

[player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithAsset:[assetItems objectAtIndex:index]]] 

這工作得很好,通過他們翻轉,但是在這之前我想用漸進式下載宣揚短mp4視頻。我使用

AVAsset *prerollAsset = [AVAsset assetWithURL:prerollURL]; 
[player replaceCurrentItemWithPlayerItem:[AVPlayerItem playerItemWithAsset:prerollAsset]]; 

它起着加載AVPlayer,但是當我像以前一樣繼續流式視頻,我得到AVPlayerStatusFailed的狀態,在AVPlayerItem錯誤The operation could not be completed

對於它的工作,我需要爲(漸進式下載)預卷創建一個AVPlayer對象,然後創建一個全新的AVPlayer對象來開始播放流式視頻。

單個AVPlayer實例可能無法播放漸進式下載視頻,然後是流式視頻嗎?或者可能還有其他事情我做錯了?

+1

我遇到同樣的問題。使用MPMoviePlayerController,我們可以設置movieSourceType屬性,但不能與AVPlayer或AVPlayerItem一起使用 –

+0

這個錯誤依然存在於iOS7.1 SDK –

+0

@KentNguyen有點晚,但您可以閱讀https://developer.apple.com/library/mac/文檔/ AudioVideo/Conceptual/AVFoundationPG/Articles/02_Playback.html,查看部分**創建並準備HTTP實況流以供播放** – onmyway133

回答

2

這個bug是一個已知的問題,據稱在iOS的下一個主要版本中已經修復。

在此期間,創建新的AVPlayer對象是唯一已知的解決方法。

+1

據WWDC14的Apple工程師介紹,iOS 8仍然存在這個問題。他們還提到,他們的優先級列表非常低。回到解決方法! – coco