美文网首页Vue
小程序-腾讯视频插件的使用

小程序-腾讯视频插件的使用

作者: 虫yu | 来源:发表于2018-07-12 11:21 被阅读54次

参考文档: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即使不用,也需要写上一个id,否则会报错

image.png

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

const TxvContext = requirePlugin("tencentvideo");

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

txvContext.play();  // 播放
txvContext.pause(); // 暂停
txvContext.requestFullScreen(); // 进入全屏
txvContext.exitFullScreen();    // 退出全屏
txvContext.playbackRate(+e.currentTarget.dataset.rate); // 设置播放速率

附注:基础库也需要选新一点的,否则也会出错

image.png

相关文章

网友评论

    本文标题:小程序-腾讯视频插件的使用

    本文链接:https://www.haomeiwen.com/subject/vxvlpftx.html