Home > Article > WeChat Applet > 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
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>
Note: You can select the album video to play through the button.
2. Then write the video.js file
Page({ /** * 页面的初始数据 */ data: { src: 'http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400', }, bindButtonTap:function(){ var that=this wx.chooseVideo({ sourceType:['album','camera'], maxDuration:60, camera:['front','back'], succes:function(res){ that.setData({ src:res.tempFilePath }) } }) } })
Rendering:
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!