一、HTML5 Video 基本介紹與設計
1.HTML5 Video 線上課程參考: https://www.w3schools.com/html/html5_video.asp
2.HTML5 video 是影片標籤,可以在瀏覽器中很容易的插入影片,設定影片長、寬、增加影片播放控制列、是否自動播放、是否自動重覆播放等功能,。
3.HTML5
video 影片標籤語法
<video src="影片連結" controls></video>
主要在網頁上嵌入視訊, 用 src 屬性指定影片來源, 並可用 width/height 屬性設定影片的大小, 也可用
autoplay、control、loop 屬性做自動播放、加入控制面板等設定。
* WebM (.webm)
* Ogg Theora Vorbis (.ogg、.ogm、.ogv 等)
* MP4 H.264 (.mp4)
4.<video>標籤屬性說明
|
二、HTML5 Video 設計案例參考
1. HTML5 Video 基本播放設計
參考資料:https://www.w3schools.com/html/tryit.asp?filename=tryhtml5_video_js_prop
<!DOCTYPE html>
|
|
2. HTML5 Video 基本播放設計
<!DOCTYPE html> <html> <body> <div style="text-align:center"> <button onclick="playPause()">Play/Pause</button> <button onclick="makeBig()">Big</button> <button onclick="makeSmall()">Small</button> <button onclick="makeNormal()">Normal</button> <br><br> <video id="video1" width="420"> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> </div> <script> 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> |
========================================================= <HTML 部分> <script> ...</script> |