video.js 視頻自動全屏播放


一 . 視頻全屏可以通過css定義寬高100%來實現。

.videoBox{
    width: 100%;
    height: 100%;
}

#example_video{
    width: 100%;
    height: 100%;
}
<div class="videoBox">
   <video id="example_video" class="video-js vjs-default-skin vjs-big-play-centered" muted autoplay controls preload="none" width="640" height="264"
   poster="http://video-js.zencoder.com/oceans-clip.png" data-setup="{}">
     <source src="https://wts.itqiche.com/u5/car_u5_video/XuHang.mp4" type='video/mp4' />
   </video>
</div>

 

二. 視頻打開頁面自動播放。

  1. 給video標簽加入<video muted></video> 靜音即可。

  2. body下面加入js代碼。

<script type="text/javascript">
    var myPlayer = videojs('example_video');
    videojs("example_video").ready(function(){
        var myPlayer = this;
        myPlayer.play(); // 自動播放
        console.log(1);
    });
</script>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM