In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you how to use wx.getRecorderManager () recording management in Mini Program. The content is simple and clear. I hope it can help you solve your doubts. Now let the editor take you to study and learn how to use wx.getRecorderManager () recording management in Mini Program.
1. Mini Program recording management introduction: wx.getRecorderManager () basic library 1.6.0 is supported, and the lower version needs to be compatible to obtain a globally unique recording manager recorderManager. two。 Mini Program recording management code / / recording management let record = function (recorderManager) {this.recorderManager = recorderManager this.recordStart ()} record.prototype = {/ / start recording start: function (startObj) {this.recorderManager.start (startObj)}, / / recording start event recordStart: function () {this.recorderManager.onStart (()) = > {console.log (this.recorderManager) 'this.recorderManager')})}} 3.Page onLoad configuration / / recording management New out the second stage instance recorderManager = wx.getRecorderManager () that.newRecord = new record (recorderManager) that.newRecord.recorderManager.onStop ((res) = > {console.log (res, 'get the recorded link')}) / / play the recording innerAudioContext = wx.createInnerAudioContext () innerAudioContext.onEnded (() = > {console.log ("end of natural audio playback")}) 4. Now start recording startRecord () {let that = this, startObj = {duration: 60000, sampleRate: 44100, numberOfChannels: 1, encodeBitRate: 192000, format: 'mp3' FrameSize: 50} / / recording start that.newRecord.start (startObj) / / recording timer recordTimeInterval = setInterval (function () {}, 1000)}, 5. Stop recording stopRecord () {clearInterval (recordTimeInterval); / / stop recording event this.newRecord.recorderManager.stop ()} 6. Play the recording / / play the recording playVoice (e) {let that = this let srcPath = e.currentTarget.dataset.temppath, / / Click the currently passed playback link duration = e.currentTarget.dataset.duration / / recording time index = e.currentTarget.dataset.index / / Index checkArr [index] = srcPath / / for page judgment to play a Another pause / / playback innerAudioContext.obeyMuteSwitch = false innerAudioContext.src = srcPath innerAudioContext.play () / / time reducer playTimeInterval = setInterval (() = > {let playTime = that.data.playTime + = 1}, 1000)} 7. Stop / / stop playing stopVoice (forIndex, e) {let index; e! = = undefined? Index = e.currentTarget.dataset.index: index = forIndex clearInterval (playTimeInterval) checkArr [index] = undefined innerAudioContext.stop ()} 8. Can only play one code / / can only play one onePlayFor (tempFilePath, src) {tempFilePath.forEach ((el) I) = > {if (el.tempFilePath! = = src) {this.stopVoice (I)}}) recording and stopping recording using Mini Program bind:touchstart='startRecord' bind:touchend='stopRecord' event above is about "how to manage wx.getRecorderManager () recording in Mini Program" If this article is helpful to you and you think it is well written, please share it with your friends to learn new knowledge. if you want to know more about it, please pay more attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.