我正在为 HTML5 视频播放器实现一个后备机制。我有办法用 swfobject 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;
}
}