video.js

作者: 金桔柠檬加冰 | 来源:发表于2018-07-28 10:42 被阅读0次

Video.js是一款优秀的HTML5 Web视频播放器。它同时支持 HTM5 和 Flash 视频,支持在桌面和移动设备上的视频播放,截至目前,大概有40W的站点在使用Video.js作为web播放器。

官网网站

https://videojs.com/
github

使用步骤

引入文件

<link rel="stylesheet" href="./lib/video.css">
<script src="/lib/video.js"></script>

初始化HTML结构

<video id="my-player" class="video-js" controls preload="auto" data-setup='{}'>
    <source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4"></source>
    <source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm"></source>
    <source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg"></source>
    <p class="vjs-no-js">
      To view this video please enable JavaScript, and consider upgrading to a web browser that
      <a href="http://videojs.com/html5-video-support/" target="_blank">
        supports HTML5 video
      </a>
    </p>
  </video>

初始化(可省略)

var myPlayer = videojs('my-player');
  videojs("my-player").ready(function () {
    var myPlayer = this;
    myPlayer.play();
  });

相关文章

网友评论

      本文标题:video.js

      本文链接:https://www.haomeiwen.com/subject/crxomftx.html