videojs会更改你给video标签设置的id,在后面加上_html5_api,但直接用videojs对象取的时候还是用一开始定义的id
网上方案1:
https://blog.csdn.net/zlb_lover/article/details/71158416
var myPlayer = videojs(‘my-video’);
videojs(“my-video”).ready(function() {
var myPlayer = this;
myPlayer.src(videoUrl); /*动态设置video.js播放的地址。*/
myPlayer.autoplay();
});
网上方案2:
https://zhuanlan.zhihu.com/p/28338413
player.pause()
var $video = $(‘video_html5_api’)
$video.attr(‘src’, newVideo)
//重载视频
player.load()
//开始视频
player.play()
上面两种方案都是失败的,说下本人方案(videojs版本6.4.0):
var myPlayer = videojs(‘example_video_1’)
myPlayer.src([
{type: “application/x-mpegURL”, src: “http://xxxxx/hls/cam.m3u8”}
])
myPlayer.play()