2010-07-14 39 views
3

我正在爲HTML5視頻播放器實現回退機制。我有一種方法可以用swfobject Flash播放器替換它,但我應該如何檢測是否有任何問題發展?HTML5視頻應該何時回落到Flash播放器?

換句話說,如果我們使用下面列出的可以拋出的錯誤事件,哪一個應該觸發Flash播放器的替換?或者,如果發生錯誤,我們是否應該簡單地進行更換?

此外,應該在哪裏調用onError處理程序?我正在考慮視頻標籤,但希望確認。非常感謝您的指導。謝謝。

function failed(e) { 
    // video playback failed - show a message saying why 
    switch (e.target.error.code) { 
     case e.target.error.MEDIA_ERR_ABORTED: 
     alert('You aborted the video playback.'); 
     break; 
     case e.target.error.MEDIA_ERR_NETWORK: 
     alert('A network error caused the video download to fail part-way.'); 
     break; 
     case e.target.error.MEDIA_ERR_DECODE: 
     alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.'); 
     break; 
     case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED: 
     alert('The video could not be loaded, either because the server or network failed or because the format is not supported.'); 
     break; 
     default: 
     alert('An unknown error occurred.'); 
     break; 
    } 
    } 

回答

8

這裏的麻煩是許多問題無法通過切換到Flash來解決。事實上,只有當你真正從Flash中獲益時,你才能在IE,FF和Opera上播放MP4,而在所有瀏覽器上播放FLV。 (這顯然是受到更改基於對WEBM/Theora的原生支持Flash。)

出於這個原因,我們已經做了JW播放器HTML5如下:

該解決方案並非萬無一失,但它可以讓您獲得90%以上的出路。

最佳,

扎克

開發,長尾視頻