转自:https://idig8.com/2018/09/22/xiaochengxujavashizhanxiaochengxushipinzujianyuapijieshao50/
这次说下,小程序的视频组件,之前在说小程序基础的时候视频组件没说,现在说下。从属性和api都说下。https://github.com/limingios/wxProgram.git 中No.15
视频组件
- 官网介绍
>https://developers.weixin..com/miniprogram/dev/component/video.html

- demo
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: '', data: { src: '', danmuList: [ { text: '第 1s 出现的弹幕', color: '#ff0000', time: 1 }, { text: '第 3s 出现的弹幕', color: '#ff00ff', time: 3 }] }, bindInputBlur: function (e) { this.inputValue = e.detail.value }, bindButtonTap: function () { var that = this wx.chooseVideo({ sourceType: ['album', 'camera'], maxDuration: 60, camera: ['front', 'back'], success: function (res) { that.setData({ src: res.tempFilePath }) } }) }, bindSendDanmu: function () { this.videoContext.sendDanmu({ text: this.inputValue, color: getRandomColor() }) } })
如果想在video组件上添加组件,可以使用cover-view组件,具体使用方法点击这里:https://mp.weixin..com/debug/wxadoc/dev/component/cover-view.html。
转载于:https://www.cnblogs.com/sharpest/p/10312333.html
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/177222.html原文链接:https://javaforall.net
