Home > WeChat Applet > Mini Program Development > How to implement video playback in a small program

How to implement video playback in a small program

angryTom
Release: 2020-03-21 11:38:08
Original
13030 people have browsed it

How to implement video playback in a small program

How to implement video playback in a mini program

You can use the video component provided by WeChat to implement video playback in a mini program.

Recommended learning: Small program development

How to implement video playback in a small program

The specific implementation methods and steps are as follows:

1 , first write the video.wxml file

<view>
    <video src="{{src}}" binderror="videoErrorCallback" style="width:100%;"></video>
    <button bindtap="bindButtonTap">获取视频</button>
</view>
Copy after login

Note: You can select the album video to play through the button.

2. Then write the video.js file

Page({
  /**
   * 页面的初始数据
   */
  data: {
    src: &#39;http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400&#39;,
  },
  bindButtonTap:function(){
    var that=this
    wx.chooseVideo({
      sourceType:[&#39;album&#39;,&#39;camera&#39;],
      maxDuration:60,
      camera:[&#39;front&#39;,&#39;back&#39;],
      succes:function(res){
        that.setData({
          src:res.tempFilePath
        })
      }
    })
  }
})
Copy after login

Rendering:

How to implement video playback in a small program

PHP Chinese website, a lot Free thinkphp tutorial, welcome to learn online!

The above is the detailed content of How to implement video playback in a small program. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template