「小程序JAVA实战」小程序视频组件与api介绍(51)

「小程序JAVA实战」小程序视频组件与api介绍(51)转自 https idig8 com 2018 09 22 xiaochengxuj 这次说下 小程序的视频组件 之前在说小程序基础的时候视频组件没说 现在说下 从属性和 api 都说下 https github com limingios wxProgram git 中 No 15 视频

转自: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

「小程序JAVA实战」小程序视频组件与api介绍(51)

 

  • 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

(0)
上一篇 2026年3月26日 下午8:01
下一篇 2026年3月26日 下午8:01


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号