HTML5-video(播放暫停視頻;開啟關閉聲音;進度條)

來源:互聯網
上載者:User

標籤:value   false   head   進度   全屏   alt   開關   isa   tle   

<!DOCTYPE html><html>   <head>          <title>HTML5-video(播放暫停視頻;開啟關閉聲音;進度條)</title>          <meta charset="utf-8"/>   </head><body><video id="video1" controls="controls" width="400px" height="400px">    <source src="videos/demo.mp4"></video><div>    <button onclick="enableMute()" type="button">關閉聲音</button>    <button onclick="disableMute()" type="button">開啟聲音</button>    <button onclick="playVid()" type="button">播放視頻</button>    <button onclick="pauseVid()" type="button">暫停視頻</button>    <button onclick="showFull()" type="button">全屏</button><br />    <span>進度條:</span>    <progress value="0" max="0" id="pro"></progress>    <span>音量:</span>    <input type="range" min="0" max="100" value="50" onchange="setvalue()" id="ran"/></div><script>    var btn=document.getElementsByTagName("button");    var myvideo=document.getElementById("video1");    var pro=document.getElementById("pro");    var ran=document.getElementById("ran");    //關閉聲音    function enableMute(){        myvideo.muted=true;        btn[0].disabled=true;        btn[1].disabled=false;    }    //開啟聲音    function disableMute(){        myvideo.muted=false;        btn[0].disabled=false;        btn[1].disabled=true;    }    //播放視頻    function playVid(){        myvideo.play();        setInterval(pro1,1000);    }    //暫停視頻    function pauseVid(){        myvideo.pause();    }    //全屏    function showFull(){        myvideo.webkitrequestFullscreen();    }    //進度條展示    function pro1(){        pro.max=myvideo.duration;        pro.value=myvideo.currentTime;    }    //拖動range進行調音量大小    function setvalue(){        myvideo.volume=ran.value/100;        myvideo.muted=false;    }</script></body></html>
:


 

HTML5-video(播放暫停視頻;開啟關閉聲音;進度條)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.