Home > Article > WeChat Applet > Analysis of Video API in WeChat Mini Program
This article mainly introduces the detailed explanation of the WeChat applet Video API example. Friends who need it can refer to it
The computer cannot test the shooting function and can only test it Select the video function, which seems to only support the mp4 format. It is worth noting that the temporary file path returned after success is a list tempFilePaths instead of the tempFilePath document. There is a problem with the writing.
Main attributes:
wx.chooseVideo(object)
Return parameters after success
wxml
<button type="primary" bindtap="listenerBtnOpenVideo">打开视频</button> <!--默认视频组件是隐藏的--> <video src="{{videoSource}}" hidden="{{videoHidden}}" style="width: 100%; height: 100%"/>
js
Page({ data:{ // text:"这是一个页面" videoSource: '', videoHidden: true }, listenerBtnOpenVideo: function() { var that = this; wx.chooseVideo({ //相机和相册 sourceType: ['album', 'camera'], //录制视频最大时长 maxDuration: 60, //摄像头 camera: ['front', 'back'], //这里返回的是tempFilePaths并不是tempFilePath success: function(res){ console.log(res.tempFilePaths[0]) that.setData({ videoSource: res.tempFilePaths[0], videoHidden: false }) }, fail: function(e) { console.log(e) } }) }, onLoad:function(options){ // 页面初始化 options为页面跳转所带来的参数 }, onReady:function(){ // 页面渲染完成 }, onShow:function(){ // 页面显示 }, onHide:function(){ // 页面隐藏 }, onUnload:function(){ // 页面关闭 } })
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
The use of input forms, redio and drop-down lists in WeChat mini programs
WeChat mini program request Request an introduction to the backend interface php
The above is the detailed content of Analysis of Video API in WeChat Mini Program. For more information, please follow other related articles on the PHP Chinese website!