This article shares the specific code for the WeChat applet to implement the Record function for your reference. The specific content is as follows layout <!--pages/record/record.wxml--> <view> <button class="tui-menu-list" bindtap="startRecordAac" type="primary">Start recording (aac)</button> <button class="tui-menu-list" bindtap="startRecordMp3" type="primary">Start recording (mp3)</button> <button class="tui-menu-list" bindtap="stopRecord" type="primary">Recording End</button> <button class="tui-menu-list" bindtap="playRecord" type="primary">Play recording</button> </view> style: /* pages/record/record.wxss */ .tui-menu-list{ flex-direction: row; margin: 20rpx; padding: 20rpx; } Start and stop recording // pages/record/record.js Page({ /** * Initial data of the page */ data: { }, onLoad:function (options) { var that = this this.recorderManager = wx.getRecorderManager(); this.recorderManager.onError(function () { that.tip("Recording failed!"); }) this.recorderManager.onStop(function (res) { that.setData({ src:res.tempFilePath }) console.log(res.tempFilePath) that.tip("Recording completed!") }) this.innerAudioContext = wx.createInnerAudioContext() this.innerAudioContext.onError((res) => { that.tip("Playing recording failed!") }) }, //tip:function (msg) { wx.showModal({ cancelColor: 'cancelColor', title:'Tips', content:msg, showCancel:false }) }, //Record aac startRecordAac:function () { this.recorderManager.start({ format:'aac' }) }, //Record mp3 startRecordMp3:function () { this.recorderManager.start({ format:'mp3' }) }, //Stop recording stopRecord:function () { this.recorderManager.stop() }, //Play the recordingplayRecord:function () { var that = this var src = this.data.src if (src='') { this.tip('Please record first') return } this.innerAudioContext.src = this.data.src this.innerAudioContext.play() } }) Effect picture: The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Interpretation of syslogd and syslog.conf files under Linux
>>: Simple writing of MYSQL stored procedures and functions
Effect: <div class="imgs"> <!-...
Table of contents 1. What is a regular expression...
Table of contents Common array methods concat() M...
Recently, I need to query all the fields in a rel...
Variables defined in SASS, the value set later wi...
Recently, when I was working on my "Football...
introduction Our company is engaged in the resear...
This article shares the specific code for JavaScr...
Cocos Creator modular script Cocos Creator allows...
1. Network Optimization YSlow has 23 rules. These...
Copy code The code is as follows: <style> ....
1. Construction 1. Prepare htpasswd.txt file The ...
Preface In web applications, in order to save tra...
1. First enter the server's mysql to modify p...
When a company builds Docker automated deployment...