vue dplayer播放m3u8地址视频


 dplayer官方配置:http://dplayer.js.org/zh/guide.html#hls

 

npm i hls.js -S --registry=http://registry.npm.taobao.org
npm i dplayer -S --registry=http://registry.npm.taobao.org

 

<script>
let Hls = require('hls.js');
import DPlayer from 'dplayer';

...

  methods: {
    initPlayer() {
      const dp = new DPlayer({
          live: true,
          autoplay: false,

          container: document.getElementById('dplayer'),
          video: {
            url: m3u8url, // 地址
            pic: picUrl,  // 封面
            
            type: 'customHls',
            customType: {
                customHls: function (video, player) {
                    const hls = new Hls();
                    hls.loadSource(video.src);
                    hls.attachMedia(video);
                },
            },
          },
        });
    }
  }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM