參考文檔: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ò)
