HTML5 audio 和 video


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" Content="text/html; charset=UTF-8" />
<meta name=keywords Content="html5">
<title>example1 input forms </title>

<script type="text/javascript">
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;
}
}

function fallback(video) {
// replace <video> with its contents
while (video.hasChildNodes()) {
if (video.firstChild instanceof HTMLSourceElement)
video.removeChild(video.firstChild);
else
video.parentNode.insertBefore(video.firstChild, video);
}
video.parentNode.removeChild(video);
}

</script>
</head>
<body>
<audio src="1.mp4" controls onerror="failed(event)">
Your browser doesn't support the audio tag
</video>
<video src="video.avi" controls onerror="failed(event)">
Your browser doesn't not support video tag
</video>

<audio controls="controls">
<source src="1.mp4">
<source src="2.mp4" onerror="fallback(parentNode)">
Your browser doesn't support the audio tag
</audio>

</body>
</html>



浏览器对音频格式的支持:
[table]
|格式 |IE 9 |Firefox 3.5 |Opera 10.5 |Chrome 3.0 |Safari 3.0|
|Ogg Vorbis | |√ |√ |√|
|MP3 |√ | | |√ |√|
|Wav | |√ |√ | |√|
[/table]

浏览器对视频格式的支持:
[table]
|格式 |IE |Firefox |Opera |Chrome |Safari|
|Ogg |No |3.5+ |10.5+ |5.0+ |No|
|MPEG 4 |9.0+ |No |No |5.0+ |3.0+|
|WebM |No |4.0+ |10.6+ |6.0+ |No|
[/table]
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值