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>
相關文章
相關標籤/搜索