Video.js 是一个通用的在网页上嵌入视频播放器的 JS 库,Video.js 自动检测浏览器对 HTML5 的支持情况,如果不支持 HTML5 则自动使用 Flash 播放器。
在页面中引用video-js.cs样式文件和video.js
<link href="video-js.css" rel="stylesheet" type="text/css"> <script src="video.js"></script>
设置flash路径,Video.js会在不支持html5的浏览中使用flash播放视频文件
<script> videojs.options.flash.swf = "video-js.swf"; </script>
html
poster="**"播放初始图。可使用三种视频格式,根据所需要格式选择对应的。
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264" poster="http://video-js.zencoder.com/oceans-clip.png" data-setup="{}"> <source src="http://video-js.zencoder.com/oceans-clip.mp4" type='video/mp4' /> <source src="http://video-js.zencoder.com/oceans-clip.webm" type='video/webm' /> <source src="http://video-js.zencoder.com/oceans-clip.ogv" type='video/ogg' /> <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 --> <track kind="subtitles" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 --> </video>
设置自动播放将下面代码加到html中代码后面
<script type="text/javascript"> var myPlayer = videojs('example_video_1'); videojs("example_video_1").ready(function(){ var myPlayer = this; myPlayer.play(); }); </script>
演示网址:http://www.jq22.com/demo/video-js/
推荐文章
2021-01-20 18:23:14
2021-01-22 17:24:38
2021-01-25 17:06:11
2021-01-28 17:37:27
2021-02-01 17:32:55
2021-02-03 17:41:37
2021-02-05 17:23:07
2021-02-08 16:59:58
稳定
产品可用性高于99.9%贴心
全国7*24小时客服热线专业
产品经理在线技术支持快速
快速上线运营快承诺
我们选择声誉坚持
10年专注高端品质开发