簡體   English   中英

Video.js通過視頻顯示當前時間

[英]Videojs Display current time through out video

我正在努力查看如何顯示視頻的當前視頻位置並更新計時器。

我希望當前視頻時間連續顯示在div #time_count中,我的代碼是

            <link href="//vjs.zencdn.net/4.11/video-js.css" rel="stylesheet">
            <script src="//vjs.zencdn.net/4.11/video.js"></script>

            <video id="example_video_1" class="video-js vjs-default-skin" controls preload="auto" width="640" height="264"
              poster="http://video-js.zencoder.com/oceans-clip.png"
              data-setup='{"example_option":true}'>
             <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' />
            </video>
            <div id="time_count"></div>
            <script>

            (function() {
                var myPlayer;
                var myTextArea = document.getElementById('time_count');

                videojs("example_video_1").ready(function(){

                    myPlayer = this;
                    myPlayer.play();
                    myPlayer.on("progress", onProgress);
                });


                function onProgress() {
                console.log(myPlayer.duration());
                  myTextArea.innerHTML = myPlayer.currentTime();
                  return false;
                }

            })();
            </script>

有任何想法嗎?

在添加評論之后,我發現解決方案應該使用timeupdate,因此它將是myPlayer.on(“ timeupdate”,onProgress)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM