In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to realize the recording and playback recording function of WeChat Mini Programs". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. let's study and learn "how to achieve the recording and playback recording function of WeChat Mini Programs"!
The API of two recordings are available on Mini Program.
Old recording function
First start the recording, then stop the recording to pull to the temporary address of the audio
Start recording:
Var that = this; wx.startRecord ({success: function (res) {/ / this function is triggered when the API to stop recording is called. Res.tempFilePath is the temporary path to the recording file var tempFilePath = res.tempFilePath that.setData ({src: tempFilePath})}, fail: function (res) {/ / handling function for recording failure}})
Stop recording:
Wx.stopRecord ()
Play the recording:
Wx.playVoice ({filePath: src / / src can be the temporary path to the recording file})
New version of recording
Get a globally unique recording manager, and then the recording depends on him, while playing the recording requires an internal audio context innerAudioContext object.
Get a globally unique recording manager:
Var that = this; this.recorderManager = wx.getRecorderManager (); this.recorderManager.onError (function () {/ / callback processing of failed recording}); this.recorderManager.onStop (function (res) {/ / after stopping recording, put the recorded audio on res.tempFilePath that.setData ({src: res.tempFilePath}) console.log (res.tempFilePath)})
Start recording:
This.recorderManager.start ({format: 'mp3' / / change to aac if recording acc type audio)
End the recording:
This.recorderManager.stop ()
Play audio:
This.innerAudioContext = wx.createInnerAudioContext (); this.innerAudioContext.onError ((res) = > {/ / callback of audio failure}) this.innerAudioContext.src = this.data.src / / here can be the temporary path to recording this.innerAudioContext.play () Thank you for your reading. The above is the content of "how to achieve the recording and playback recording function of WeChat Mini Programs". After the study of this article, I believe you have a deeper understanding of how WeChat Mini Programs realizes the recording and playback recording function, and the specific use still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.