htm5 vido.js 播放器

來源:互聯網
上載者:User

標籤:style   blog   http   io   color   os   ar   java   sp   

需求:頁面中有2個普通按鈕a,b。還有一個video標籤,能成功播放出視頻。。我想要的效果是,點擊a按鈕,視頻開始播放,點擊b按鈕,視頻播放停止!!!
----------------------------------------------------code---------------------------------------------------------------------------
<!DOCTYPE html><html> <head> <title>Simple JavaScript Controller</title> <script type="text/javascript"> function playPause() { var myVideo = document.getElementsByTagName(‘video‘)[0]; //擷取視頻video if (myVideo.paused){ myVideo.play(); }else{ myVideo.pause(); } function makeBig() { //全屏 高度2倍 var myVideo = document.getElementsByTagName(‘video‘)[0]; myVideo.height = (myVideo.videoHeight * 2 ) ; } function makeNormal() { //取消全屏 var myVideo = document.getElementsByTagName(‘video‘)[0]; myVideo.height = (myVideo.videoHeight) ; } </script> </head> <body> <div class="video-player" align="center">    <video src="myMovie.m4v" poster="poster.jpg" ></video> <!--視頻 --> <br> <a href="javascript:playPause();">Play/Pause</a> <br> <!--播放 暫停--> <a href="javascript:makeBig();">2x Size</a> <!--放大視頻--> [解決辦法] <a href="javascript:makeNormal();">1x Size</a> <br> <!--還原視頻 --> </div> </body></html>

 [解決辦法]:

var myVideo = document.getElementsByTagName(‘video‘)[0];可以換成document.getElementById(‘videoId‘);<video src="myMovie.m4v" poster="poster.jpg" id="videoId"></video>[解決辦法]額。來晚了。。。停止的話...myVideo.currentTime = 0;    //屬性設定或返迴音頻/視頻播放的當前位置(以秒計)。當設定該屬性時,播放會跳躍到指定的位置。myVideo.pause();------解決方案--------------------mark 

 原文地址:http://www.reader8.cn/jiaocheng/20130619/1350009.html

       http://www.reader8.cn/jiaocheng/javascript/

htm5 vido.js 播放器

聯繫我們

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