In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to play audio by WeChat Mini Programs". In daily operation, I believe many people have doubts about how WeChat Mini Programs can play audio. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to play audio by WeChat Mini Programs"! Next, please follow the editor to study!
Function introduction
Let's look at the picture first. Press the [EditAction] button on the specified monitoring point location screen to enter the monitoring condition setting screen below. At present, it is not even a prototype, it is just a test screen for playing audio.
When the user selects a tone, the corresponding audio is played.
Here I will directly show you the code of the playback part.
Editaction.wxml
Action type: {{type_ array [type _ index]}}
When the user changes the selected item, bingTypeChange is called, and the parameter is the index of the selected item.
Editaction.js
BindTypeChange: function (e) {
Var Urls = ['https://raw.githubusercontent.com/xueweiguo/alarmmap/master/ringtones/store_01',
'https://raw.githubusercontent.com/xueweiguo/alarmmap/master/ringtones/store_04',
'https://raw.githubusercontent.com/xueweiguo/alarmmap/master/ringtones/store_06']
Var fileUrl = Urls [e.detail.value]
Wx.downloadFile ({
Url: fileUrl
Success: function (res) {
Wx.playVoice ({
FilePath: res.tempFilePath
})
}
})
}
This code is just a prototype, first download it to the corresponding file, and then play the saved file. The reason why I want to save it is that I don't want to download it every time. The actual file is selected from the three specified files.
In order to be able to download files from the specified website, you also need to set the file download domain name in advance.
A little feeling.
According to the various restrictions imposed by Tencent on Mini Program, it seems that Mini Program can only be Mini Program.
Mini Program Code
Another thing has been done these days: the code has been uploaded to GitHub. In this way, you can see the progress of Mini Program at any time. Welcome to visit, patting bricks.
Https://github.com/xueweiguo/alarmmap
After opening the above link, the picture looks like this.
In fact, if you look at the code carefully, you will find that audio files are also stored on GitHub.
At this point, the study on "how to play audio by WeChat Mini Programs" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.