popcorn-js視頻Video架構簡單用法

來源:互聯網
上載者:User

標籤:功能   listen   重設   get   list   upd   eset   request   rip   

 <div>             <video class="video" id="ourvideobig" preload="auto" controls="controls">                <source src="/File/video/1.mp4" />            </video>        </div>

  

<script>        //視頻列表 便於多個視頻切換        var videos = ["/File/video/1.mp4", "/File/video/2.mp4", "/File/video/3.mp4", "/File/video/4.mp4", "/File/video/5.mp4"];        var activityTab = 0; //視頻切換值        var pop = null;        var $video = null;        var init = function () {            pop = Popcorn("#ourvideobig");            $video = document.getElementById("ourvideobig");            loadedReady(); //視頻載入完畢執行事件        }        $(function () {            init();//初始化        })        var wait = 0;        //視頻載入完畢執行事件        function loadedReady() {            var rdy = pop.readyState();//擷取視頻狀態            if (rdy == 4)//載入完畢            {                $("#msg").html("視頻總時間:" + pop.duration());                //console.log("視頻總時間:" + pop.duration());                timeupdate();//動態監聽播放時間            }            else {                console.log("視頻狀態:" + rdy + ",次數=" + wait);                //迴圈                if (wait <= 10) {                    // console.log("wait:" + wait);                    setTimeout(loadedReady, 200);                    wait++;                }            }        }        //綁定動態監聽播放時間        function timeupdate() {            $video.addEventListener("timeupdate", function (e) {                $("#txt_msg").val("當前播放時間:" + $video.currentTime);                //可以用於自動切換功能            });        }        //綁定拖動視頻時間        function seeked() {            $video.addEventListener("seeked", function (e) {                console.log("當前視頻拖動時間:" + $video.currentTime);            });        }        //重設視頻 即把視頻目前時間設定為0        function reset() { pop.currentTime(0); }        //停止視頻        function destroy() {            pop.currentTime(0);            pop.pause();//暫停        }        //全屏        function fullscreen() { $video.webkitRequestFullScreen(); } </script>

  

popcorn-js視頻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.