小程序实例 | 视频播放加弹幕效果
js Page({
onReady(res) {
this.videoContext = wx.createVideoContext('myVideo')
},
inputValue: '',
data: {
src: '',
danmuList: [
// {
// text: '第 1s 出现的弹幕',
// color: '#ff0000',
// time: 1
// },
// {
// text: '第 3s 出现的弹幕',
// color: '#ff00ff',
// time: 3
// }
]
},
bindInputBlur(e) {
this.inputValue = e.detail.value
},
bindButtonTap() {
const that = this
wx.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: ['front', 'back'],
success(res) {
that.setData({
src: res.tempFilePath
})
}
})
},
bindSendDanmu() {
this.videoContext.sendDanmu({
text: this.inputValue,
color: '#ccc'
})
}
}) wxml wxss
/* pages/video/index.wxss */
#myVideo{
width: 100%
} 本站文章如未注明出处均为原创,转载请注明出处,如有侵权请邮件联系站长。