HTML5筆記之——視頻

來源:互聯網
上載者:User

標籤:amp   height   style   func   .com   image   get   例子   不同的   

一、HTML5視頻  1、支援的格式

  

  2、格式
<video src="movie.ogg" width="320" height="240" controls="controls">Your browser does not support the video tag.</video>

  control 屬性供添加播放、暫停和音量控制項。

  <video> 與 </video> 之間插入的內容是供不支援 video 元素的瀏覽器顯示的。

  video 元素允許多個 source 元素。source 元素可以連結不同的視頻檔案。瀏覽器將使用第一個可識別的格式:

<video width="320" height="240" controls="controls">  <source src="movie.ogg" type="video/ogg">  <source src="movie.mp4" type="video/mp4">  Your browser does not support the video tag.</video>

  

  3、屬性  

  

 

  4、方法、屬性、事件  

  HTML5 <video> 元素同樣擁有方法、屬性和事件。

  其中的方法用於播放、暫停以及載入等。其中的屬性(比如時間長度、音量等)可以被讀取或設定。其中的 DOM 事件能夠通知您,比方說,<video> 元素開始播放、已暫停,已停止,等等。

  

例子:

<!DOCTYPE html> <html> <body> <div style="text-align:center;">  <button onclick="playPause()">播放/暫停</button>   <button onclick="makeBig()">大</button>  <button onclick="makeNormal()">中</button>  <button onclick="makeSmall()">小</button>  <br />   <video id="video1" width="420" style="margin-top:15px;">    <source src="/example/html5/mov_bbb.mp4" type="video/mp4" />    <source src="/example/html5/mov_bbb.ogg" type="video/ogg" />    Your browser does not support HTML5 video.  </video></div> <script type="text/javascript">var myVideo=document.getElementById("video1");function playPause(){ if (myVideo.paused)   myVideo.play(); else   myVideo.pause(); } function makeBig(){ myVideo.width=560; } function makeSmall(){ myVideo.width=320; } function makeNormal(){ myVideo.width=420; } </script> </body> </html>

 

HTML5筆記之——視頻

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.