小程序-騰訊視頻插件的使用

參考文檔:https://mp.weixin.qq.com/wxopen/plugindevdoc?appid=wxa75efa648b60994b&token=1327615254&lang=zh_CN&scene=21&uin=&key=&devicetype=Windows+7&version=6206034d&ascene=1&winzoom=1
參考資料:https://www.hishop.com.cn/xiaocx/show_55733.html

app.json文件:

  "plugins": {
    "tencentvideo": {
      "version": "1.1.1",
      "provider": "wxa75efa648b60994b"
    }
  }

使用插件的頁面的json文件中:

{
  "navigationBarTitleText": "騰訊插件的使用",
  "usingComponents": {
    "txv-video": "plugin://tencentvideo/video"
  }
}

使用插件的頁面的wxml文件中:

<view class="video">
  <txv-video class="txv-video" playerid="txv1" vid="w0718gzpyqm" autoplay="true"></txv-video>
</view>

附注:playerid即使不用,也需要寫上一個(gè)id,否則會(huì)報(bào)錯(cuò)

如果需要使用js控制播放:

const TxvContext = requirePlugin("tencentvideo");

let txvContext = TxvContext.getTxvContext('txv1') // txv1即播放器組件的playerid值

txvContext.play();  // 播放
txvContext.pause(); // 暫停
txvContext.requestFullScreen(); // 進(jìn)入全屏
txvContext.exitFullScreen();    // 退出全屏
txvContext.playbackRate(+e.currentTarget.dataset.rate); // 設(shè)置播放速率

附注:基礎(chǔ)庫也需要選新一點(diǎn)的,否則也會(huì)出錯(cuò)

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容