转自: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. HDU 4751 Divide Groups (2-SAT)

    题意 给定一个有向图,问是否能够分成两个有向完全图. 思路 裸的2-sat--我们设一个完全图为0,另一个完全图为1,对于一个点对(u, v),如果u.v不是双向连通则它们两个不能在一组,即u和v至少 ...

  2. MAPE 平均绝对百分误差

    from fbprophet.diagnostics import performance_metrics df_p = performance_metrics(df_cv) df_p.head() ...

  3. $'\r': command not found in Cygwin

    这是因为windows下的回车符改为Unix下的回车符,用以下命令可以批量修改. dos2unix ./*

  4. Class 'SoapClient' not found 解决方法

    Class 'SoapClient' not found ? 在百度上搜了解决办法,可是收效不佳,只知道好像要添加soap扩展模块,但怎么添加却没有说.于是,我上了google.果然,查看一些英文资料 ...

  5. Type Script在Visual Studio 2013中的问题汇总(持续更新…)

    TypeScript在vs2012下的问题 TypeScript对VS2012支持度比较低,建议升级为VS2013版本以上. 在VS2013中无法创建TypeScript项目 VS2013默认不支持T ...

  6. 【linux】查看进程

    查询所有:ps aux 查询某个用户:ps -u abc 终止某个进程:kill

  7. matlab 读多个文件夹(有名字规律)中的文件名字保存到txt中

    save_file_name='C:\Users\cong\Desktop\研一实战\项目\图像中时间数字识别\OCR\result6\'; :: image_path=strcat('C:\User ...

  8. BZOJ3295: [Cqoi2011]动态逆序对(树状数组套主席树)

    3295: [Cqoi2011]动态逆序对 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 7465  Solved: 2662[Submit][Sta ...

  9. Map集合统计字母次数

    Map集合练习:"asfefxAAcf34vrfdfse2-2asd--wdd"获取该字符串中,每一个字母出现的次数要求打印的结果是:a(2)c(1)...;思路:对结果分析发现, ...

  10. BZOJ4350: 括号序列再战猪猪侠【区间DP】

    Description 括号序列与猪猪侠又大战了起来. 众所周知,括号序列是一个只有(和)组成的序列,我们称一个括号序列S合法,当且仅当: 1.( )是一个合法的括号序列. 2.若A是合法的括号序列, ...