Home  >  Article  >  WeChat Applet  >  Analysis of Video API in WeChat Mini Program

Analysis of Video API in WeChat Mini Program

不言
不言Original
2018-06-27 10:49:333386browse

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: &#39;&#39;,
  videoHidden: true
 },

 listenerBtnOpenVideo: function() {
   var that = this;
   wx.chooseVideo({
     //相机和相册
     sourceType: [&#39;album&#39;, &#39;camera&#39;],
     //录制视频最大时长
     maxDuration: 60,
     //摄像头
     camera: [&#39;front&#39;, &#39;back&#39;],
     //这里返回的是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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn