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;
}
}