Vue播放m3u8视频格式,Video.js,

首先,我们需要在vue工程中安装video.js相关依赖。

npm install --save video.js
npm install --save videojs-contrib-hls

引入js对象


import videojs from  'video.js/dist/video.min'
  import 'video.js/dist/video-js.min.css'
  import 'videojs-flash/dist/videojs-flash';

videojs-contrib-hls 用于在电脑端播放 如果只需手机播放可以不引入


最后,我们在mounted节点初始化播放器:


videojs('my-video', {
    bigPlayButton: false,
    textTrackDisplay: false,
    posterImage: true,
    errorDisplay: false,
    controlBar: true
}, function () {
    this.play()
})

多视频列表循环播放代码



export default {
  data() {
    return {
      vedioData: [
        {
          region: "烟台市蓬莱阁景区1",
          path:
            "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8",
          type: "application/x-mpegURL" //播放hls流
        },
         {
          region: "烟台市蓬莱阁景区2",
          path:
            "http://1252093142.vod2.myqcloud.com/4704461fvodcq1252093142/f865d8a05285890787810776469/playlist.f3.m3u8",
          type: "application/x-mpegURL" //播放hls流
        },
      ]
    };
  },
mounted() {
//id必须是唯一的,遍历id,
    for(let i=0;i

转载于:(https://blog.csdn.net/xingchen678/article/details/100900846)

你可能感兴趣的:(Vue播放m3u8视频格式,Video.js,)