转自:https://idig8.com/2018/09/22/xiaochengxujavashizhanxiaochengxushipinzujianyuapijieshao50/

这次说下,小程序的视频组件,之前在说小程序基础的时候视频组件没说,现在说下。从属性和api都说下。https://github.com/limingios/wxProgram.git 中No.15

视频组件

  • 官网介绍
    >https://developers.weixin.qq.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()
})
}
})


<view class="section tc">
<video id="myVideo" src="https://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" danmu-list="{{danmuList}}" enable-danmu danmu-btn controls></video>
<view class="btn-area">
<button bindtap="bindButtonTap">获取视频</button>
<input bindblur="bindInputBlur"/>
<button bindtap="bindSendDanmu">发送弹幕</button>
</view>
</view>

PS: 最后补充一下video的注意事项:
1. video 组件是由客户端创建的原生组件,它的层级是最高的。
2. 请勿在 scroll-view 中使用 video 组件。
3. css 动画对 video 组件无效。

如果想在video组件上添加组件,可以使用cover-view组件,具体使用方法点击这里:https://mp.weixin.qq.com/debug/wxadoc/dev/component/cover-view.html

「小程序JAVA实战」小程序视频组件与api介绍(51)的更多相关文章

  1. 「小程序JAVA实战」小程序首页视频(49)

    转自:https://idig8.com/2018/09/21/xiaochengxujavashizhanxiaochengxushouyeshipin48/ 视频显示的内容是视频的截图,用户的头像 ...

  2. 「小程序JAVA实战」小程序视频封面处理(48)

    转自:https://idig8.com/2018/09/16/xiaochengxujavashizhanxiaochengxushipinfengmianchuli47/ 截图这块,在微信小程序工 ...

  3. 「小程序JAVA实战」小程序上传短视频(46)

    转自:https://idig8.com/2018/09/14/xiaochengxujavashizhanxiaochengxushangchuanduanshipin45/ 个人信息:用户上传短视 ...

  4. 「小程序JAVA实战」小程序视频展示页开发(52)

    转自:https://idig8.com/2018/09/22/xiaochengxujavashizhanxiaochengxushipinzhanshiyekaifa51/ 这次说下,小程序的视频 ...

  5. 「小程序JAVA实战」小程序多媒体组件(27)

    转自:https://idig8.com/2018/08/19/xiaochengxujavashizhanxiaochengxuduomeitizujian27/ 来说下 ,小程序的多媒体组件.源码 ...

  6. 「小程序JAVA实战」小程序的表单组件(25)

    转自:https://idig8.com/2018/08/18/xiaochengxujavashizhanxiaochengxudebiaodanzujian25/ 来说下 ,小程序的基础组件.源码 ...

  7. 「小程序JAVA实战」小程序的flex布局(22)

    转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-22/ 之前已经把小程序的框架说完了,接下来说说小程序的组件,在说组件之前,先说说布局吧.源码:ht ...

  8. 「小程序JAVA实战」小程序的留言和评价功能(70)

    转自:https://idig8.com/2018/10/28/xiaochengxujavashizhanxiaochengxudeliuyanhepingjiagongneng69/ 目前小程序这 ...

  9. 「小程序JAVA实战」小程序的举报功能开发(68)

    转自:https://idig8.com/2018/09/25/xiaochengxujavashizhanxiaochengxudeweixinapicaidancaozuo66-2/ 通过点击举报 ...

随机推荐

  1. 124. Binary Tree Maximum Path Sum *HARD* -- 二叉树中节点和最大的路径的节点和

    Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence ...

  2. R语言rJava包安装载入及JAVA环境配置

    rJava 包的安装与载入 一般文本分词的教程都会贴出: install.packages("rJava") library(rJava) 来引导我们装载rJava包,运行inst ...

  3. Xcode 7.0 Could not find developer disk image

    在使用Xcode 7的真机运行的时候, 出现Could not find developer disk image. 解决方法:先关闭Xcode.再从Xcode 6.4中,拷贝8.4 (12H141) ...

  4. eclipse 编码设置【转】

    一般Java文件编码格式是UTF-8的.以下以默认GBK改为UTF-8为例. 1.改变整个工作空间的编码格式,这样以后新建的文件也是新设置的编码格式. eclipse->window->p ...

  5. Git Error: warning: refname 'origin/branch-name' is ambiguous.

    When this happened, it created the file .git/refs/heads/origin/branch-name. So, I just deleted the f ...

  6. java IO 学习(三)

    java IO 学习(一)给了java io 进行分类,这一章学习这些类的常用方法 一.File 1.创建一个新的File的实例: /** * 创建一个新的File实例 */ File f = new ...

  7. IOS NSBundle的使用,注意mainBundle和Custom Bundle的区别

    1.[NSBundle mainBundle],文件夹其实是Group,如左侧的树形文件管理器 Build之后,文件直接就复制到了根目录下,于是读取的方法,应该是这样: NSString *earth ...

  8. 宏使用 Tricks

    人为地定义一些"无意义"的宏(宏名本身有意义),以起到提升代码程序的可读性. 1. IN/OUT 指定参数用于输入还是输出: #define IN #define OUT void ...

  9. CentOS 6&7安装ffmpeg

    CentOS 6和7安装方法是不一样的,下面分别说明: 安装前都需要先安装epel扩展源 yum -y install epel-release CentOS 6比较简单,安装yum源之后直接安装即可 ...

  10. Windows与.NET Framework、数据库版本对应关系

    ================== windows XP/server 2003 (.NET Framework与 SQL Server\Oracle) 支持.NET版本:.NET Framewor ...