微信小程序videoContext怎么用

发布时间:2022-03-10 14:39:54 作者:iii
来源:亿速云 阅读:540

这篇文章主要介绍了微信小程序videoContext怎么用的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇微信小程序videoContext怎么用文章都会有所收获,下面我们一起来看看吧。

wx.createVideoContext(videoId)


创建并返回 video 上下文videoContext对象

videoContext

videoContext通过 videoId 跟一个 video 组件绑定,通过它可以操作一个 video 组件。

videoContext对象的方法列表:

方法 参数 说明 最低版本
play 播放  
pause 暂停  
seek position 跳转到指定位置,单位 s  
sendDanmu danmu 发送弹幕,danmu 包含两个属性 text, color。  
playbackRate rate 设置倍速播放,支持的倍率有 0.5/0.8/1.0/1.25/1.5 1.4.0
requestFullScreen 进入全屏 1.4.0
exitFullScreen 退出全屏 1.4.0

示例代码:

<view class="section tc">  <video id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"   enable-danmu danmu-btn controls></video>
  <view class="btn-area"><input bindblur="bindInputBlur"/><button bindtap="bindSendDanmu">发送弹幕</button>
  </view></view>
function getRandomColor () {  let rgb = []  for (let i = 0 ; i < 3; ++i){let color = Math.floor(Math.random() * 256).toString(16)
    color = color.length == 1 ? '0' + color : color
    rgb.push(color)
  }  return '#' + rgb.join('')
}

Page({
  onReady: function (res) {this.videoContext = wx.createVideoContext('myVideo')
  },
  inputValue: '',
  bindInputBlur: function(e) {this.inputValue = e.detail.value
  },
  bindSendDanmu: function () {this.videoContext.sendDanmu({
      text: this.inputValue,
      color: getRandomColor()
    })
  }
})

关于“微信小程序videoContext怎么用”这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对“微信小程序videoContext怎么用”知识都有一定的了解,大家如果还想学习更多知识,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. 微信小程序模板template怎么用
  2. 微信小程序中this和that怎么用

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

微信小程序

上一篇:微信小程序选择器怎么用

下一篇:微信小程序如何做店铺

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》