uni-app:录音并播放(hbuilderx 3.7.3)
App 播放 uni 3.7 录音 HBuilderX
2023-09-14 09:01:15 时间
一,官方文档地址
https://uniapp.dcloud.net.cn/api/media/record-manager.html
说明:刘宏缔的架构森林是一个专注架构的博客,地址:https://www.cnblogs.com/architectforest
对应的源码可以访问这里获取: https://github.com/liuhongdi/
或: https://gitee.com/liuhongdi
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,js代码:
<template> <view> <button @click="startRecord">开始录音</button> <button @click="stopRecord">停止录音</button> <button @click="playRecord">播放录音</button> </view> </template> <script> export default { data() { return { tempPath:'', //声音文件的临时保存地址 } }, onLoad(){ this.music = uni.createInnerAudioContext(); //播放 this.record = uni.getRecorderManager(); //录音 this.record.onStop((res)=>{ this.tempPath = res.tempFilePath; //保存声音的临时文件地址 } ); }, methods: { startRecord(){ //开始录音 this.record.start(); }, stopRecord(){ //停止录音 this.record.stop(); }, playRecord(){ //播放录音 if (this.tempPath!='') { this.music.src = this.tempPath; this.music.play(); } } } } </script> <style> </style>
三,查看效果
四,查看hbuilderx的版本:
![](https://img2023.cnblogs.com/blog/1938691/202302/1938691-20230224142225914-1929024108.png)
相关文章
- [Android] 解析android framework下利用app_process来调用java写的命令及示例
- 7步学会在Windows下上架iOS APP流程
- Reveal App试用时间破解
- uni-app:微信小程序:使用位置权限getlocation时报错(hbuilderx 3.7.3)
- app开发流程
- 疯狂暗示!一次对某色情app的渗透
- uni-app:播放视频(hbuilderx 3.7.3)
- wx.getUserProfile is not a function;at App onError function;at api showModal
- iOS swift app启动不走Main.storyboard
- iOS 如何查看app的崩溃报告
- Android 12.0 内置app编译报错编不过的解决方案
- 快速定位 Android APP 当前页面的三种方法(Activity / Fragment)
- 2020年的UWP(2)——In Process App Service
- uni-app_uView1.0 输入框右侧上下箭头(下拉菜单)