1. 程式人生 > 其它 >vue中使用騰訊視訊播放器

vue中使用騰訊視訊播放器

技術標籤:vue騰訊vue

參考:https://m.v.qq.com/txp/v3/src/jsapi/

下載騰訊視訊的js

https://vm.gtimg.cn/tencentvideo/txp/js/txplayer.js

http://vm.gtimg.cn/tencentvideo/txp/js/txplayer.js

在頁面新建一個視訊播放的父級div

<div id="container" class="video-wrapper"></div>

引入騰訊視訊js

import "../../../service/txplayer";// 這裡放騰訊視訊js在本地的路徑

建立播放:

 playerInit(vid) {//呼叫且傳騰訊視訊的id即可
      var player = new Txplayer({
        containerId: "container",//上面第一步html的id
        vid: vid,
        width: "100%",
        height: screen.availHeight / 3,
        autoplay: true,
      });
    },