In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Today, I would like to share with you the relevant knowledge points about how to solve the sound problem in Mini Program ios audio playback. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.
Mini Program provides the ability to record and play audio. Since the base library 1.6.0, it supports wx.getRecorderManager (). All recordings use api provided by wx.getRecorderManager (), and audio files are played using api provided by wx.createInnerAudioContext ().
Import recording and playback audio function
Const recorderManager = wx.getRecorderManager (); / / recording function const innerAudioContext = wx.createInnerAudioContext (); / / play audio
Registration recording end event
/ / end of recording recorderManager.onStop ((res) = > {console.log ('recorder stop'); const {tempFilePath} = res; / / Local temporary file for recording / /. Play audio innerAudioContext.src = tempFilePath; innerAudioContext.play ();})
Start recording
Const options = {duration: 10000, sampleRate: 44100, numberOfChannels: 1, encodeBitRate: 192000, format: 'aac', frameSize: 50} recorderManager.start (options)
Options is some audio configuration. For specific configuration, please see the official documentation.
This creates a simple audio recording and playback function
Ios plays audio files without sound
In the process of development, it was found that the recording files could be recorded and played normally on the developer tools and Android test machines, but no sound was found in the audio file playback on the ios phone. Baidu did not find any similar problems, so it had to test on its own. Finally, it was found that the ios phone was in mute mode! Sure enough, cancel the mute mode and it will play normally.
In fact, if you take a closer look at the api document, you can find a property obeyMuteSwitch in the property list of the innerAudioContext object, which can play the audio file in mute mode and has sound!
Whether to follow the system mute switch. When this parameter is false, the user can continue to produce sound even if the mute switch is turned on. Default is true.
You can set obeyMuteSwitch to false to enable audio playback in mute mode! Solved the problem that there is no sound when playing audio files in ios mute mode!
InnerAudioContext.obeyMuteSwitch = false; above is "Mini Program ios audio playback does not sound how to solve" all the contents of this article, thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay 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.
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.