Open AlexZ33 opened 4 years ago
安装video.js
yarn add video.js videojs-flash //千万不要下载错了,下载前去npm上面搜索一番,选择下载量最高的
//vue
import Vue from "vue";
import video from 'video.js';
import 'videojs-flash'; // 引入videojs flash
Vue.prototype.$video = video; // 将video.js 实例放在Vue原型上
<template>
<div>
<video id="example_video_1" class="video-js vjs-default-skin" controls preload="auto" width="1280" height="720" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<source src="rtmp://live.hkstv.hk.lxdns.com/live/hks2" type="rtmp/flv">
</video>
<video id="example_video_2" class="video-js vjs-default-skin" controls preload="auto" width="1280" height="720" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<source src="rtmp://video.zhiguaniot.com/test01/stream01?auth_key=1552979972-0-0-3502db2f66a4560c886f44c7f68e20d5" type="rtmp/flv">
</video>
<video id="example_video_3" class="video-js vjs-default-skin" controls preload="auto" width="1280" height="720" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<source src="rtmp://live.hkstv.hk.lxdns.com/live/hks2" type="rtmp/flv">
</video>
<video id="example_video_4" class="video-js vjs-default-skin" controls preload="auto" width="1280" height="720" poster="http://vjs.zencdn.net/v/oceans.png" data-setup="{}">
<source src="rtmp://live.hkstv.hk.lxdns.com/live/hks2" type="rtmp/flv">
</video>
</div>
</template>
export default {
name: 'video',
data() {
return {}
},
mounted() {
this.playervideo('example_video_1');
this.playervideo('example_video_2');
this.playervideo('example_video_3');
this.playervideo('example_video_4');
},
methods: {
playervideo(id) {
var player = this.$video(id, {}, function onPlayerReady() {
this.play();
this.on('ended', function() {
console.log('Awww...over so soon?!');
});
});
}
}
}
streamroot/videojs-hlsjs-plugin 注意:HLS 在 PC 端仅支持safari浏览器,类似chrome浏览器使用HTML5 video标签无法播放 m3u8 格式,可直接采用网上一些比较成熟的方案,如:sewise-player、MediaElement、videojs-contrib-hls、jwplayer。
I found two of the most powerful hls library for video js
1.videojs-http-streaming
This library has been generated from videojs-contrib-hls Based on the following description
Notice: this project will be deprecated and is succeeded by videojs-http-streaming. VHS supports HLS and DASH and is built into video.js 7, see the video.js 7 blog post
The short description of videojs-http-streaming library is as follows
Play HLS, DASH, and future HTTP streaming protocols with video.js, even where they're not natively supported. Included in video.js 7 by default!.
Github link: https://github.com/yanwsh/videojs-panorama
2.videojs-hlsjs-plugin
The short description of this library is as follows
Adds HLS playback support to video.js 5.0+ using hls.js library.
The library's strength in using it from the hls.js library
videojs-hlsjs-plugin github link : https://github.com/streamroot/videojs-hlsjs-plugin
hls.js github link : https://github.com/video-dev/hls.js/
conclusion
I used projects from both of these libraries and my experience in using them is that videojs-hlsjs-plugin library is due to using a powerful hls.js library can be a great option for large projects.
video.js
video.js 播放 rtsp、hls
HLS
RTSP
RTMP