HTML5的video元素

  • <video>标记语法格式以下。

<video src="url" controls="controls">替代文字</video>html

属性 说明
src url 要播放视频的URL
controls controls 添加播放、暂停和音量等控件

 

 

 

 

<video width="320px" height="240px" controls="controls">

<source src="movie.ogg" type="video/ogg"/>

<source src="movie.mp4" type="video/mp4"/>

<source src="movie.webm" type="video/webm"/>

 

您的浏览器不支持video标记web

</video>浏览器

play() 播放媒体,paused属性的值自动修改成false
pause() 暂停媒体,paused属性的值自动修改成true

 

 

 

<video id="myVideo" width="320" height="240" controls>

<source src="images/lego.ogv" type="video/ogv">

<source src="images/lego.mp4" type="video/mp4">

<source src="images/lego.webm" type="video/webm">

<object data=" images/lego.mp4" width="320" height=“240”>

        <embed width="320" height="240" src=" images/lego.swf">

</object>

</video>

 

<br>

  

<button onClick="document.getElementById('myVideo').play()">播放</button>

<button onClick="document.getElementById('myVideo').pause()">暂停</button>

<button onClick="document.getElementById('myVideo').volume += 0.1">音量+</button>

<button onClick="document.getElementById('myVideo').volume -= 0.1">音量-</button>

<button onClick="document.getElementById('myVideo').muted = true"> 静音</button>

<button onClick="document.getElementById('myVideo').muted = false">取消静音</button>
相关文章
相关标签/搜索