微信小程序视频格式有哪些?怎么使用小程序视频功能?
自从微信小程序官方推出了视频功能,现在很多人都乐于使用小程序了,但是作为开发者来说,想要将视频上传到小程序需要一定的微信小程序视频格式,微信小程序视频格式到底是什么格式?要怎么使用微信小程序视频功能?以下是具体解答。
应该和QQ浏览器的支持差不多,格式如下:
1、封装格式:
m3u8、ts、mp4、3gp、asf、wmv、avi、mkv、rmvb、flv、mp3、ogg、amr
2、解码器格式:
1)视频:h264;h263;mpeg4;wmv1、wmv2、wmv3;rv10、rv20、rv30、rv40;msvideo1;theora;mjpeg
2)音频:aac;ac3;mp3、mp3adu、mp3adufloat、mp3float、mp3on4、mp3on4float;amrnb、amrwb;cook;ra_144、ra_288;sipr;wmav1、wmav2、wmavoice、wmapro、wamlossless;nellymoser;vorbis
那么怎么使用小程序视频功能呢?
使用时需要编辑wxml与js文件。
wxml文件:
[html] view plain copy print?
发送小程序视频弹幕
跳转到50s播放
发送弹幕
跳转到50s播放
js文件:
[html] view plain copy print?
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: '',
bindInputBlur: function(e) {
this.inputValue = e.detail.value
},
bindSendDanmu: function () {
this.videoContext.sendDanmu({
text: this.inputValue,
color: getRandomColor()
})
},
savePosition: function (){
//视频跳转播放。
this.videoContext.seek(50.0);
}
})
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: '',
bindInputBlur: function(e) {
this.inputValue = e.detail.value
},
bindSendDanmu: function () {
this.videoContext.sendDanmu({
text: this.inputValue,
color: getRandomColor()
})
},
savePosition: function (){
//视频跳转播放。
this.videoContext.seek(50.0);
}
})
上文中详细介绍了微信小程序视频格式以及如何使用小程序视频功能,相信大家对于微信小程序视频的了解又多了一些,如果还有不懂的地方欢迎在微信小程序商店进行搜索。
微信小程序视频实例,开发小程序视频实例
怎么添加微信小程序宣传视频?
微信小程序发布视频怎么弄?
下一篇:微信小程序编码格式怎么修改?
