我正在实现HTML5视频播放器的备用机制。我已经找到了一种方法来使用swfobject Flash播放器替换它,但是如何检测是否存在任何问题呢?
换句话说,如果我们使用以下可能抛出的错误事件列表,那么哪个事件应该触发Flash播放器的替换?或者我们应该在抛出任何错误时进行替换?
此外,onError处理程序应该在哪里调用?我想在video标签上进行,但希望确保。非常感谢您的指导。谢谢。
换句话说,如果我们使用以下可能抛出的错误事件列表,那么哪个事件应该触发Flash播放器的替换?或者我们应该在抛出任何错误时进行替换?
此外,onError处理程序应该在哪里调用?我想在video标签上进行,但希望确保。非常感谢您的指导。谢谢。
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;
}
}