这个功能实现起来并不麻烦 参考官方文档的API 根据API调试一下就可以
官方文档也有相应的示例 uni.getRecorderManager() | uni-app官网 (dcloud.net.cn)
获取全局唯一的录音管理器 recorderManager
HTML
<template> <view> <button @tap="startRecord">开始录音</button> <button @tap="endRecord">停止录音</button> <button @tap="playVoice">播放录音</button> </view> </template>
JS
const recorderManager = uni.getRecorderManager(); const innerAudioContext = uni.createInnerAudioContext(); innerAudioContext.autoplay = true; export default { data() { return { text: 'uni-app', voicePath: '' } }, onLoad() { let self = this; recorderManager.onStop(function (res) { console.log('recorder stop' + JSON.stringify(res)); self.voicePath = res.tempFilePath; }); }, methods: { startRecord() { console.log('开始录音'); recorderManager.start(); }, endRecord() { console.log('录音结束'); recorderManager.stop(); }, playVoice() { console.log('播放录音'); if (this.voicePath) { innerAudioContext.src = this.voicePath; innerAudioContext.play(); } } } }
大家根据自己的情况和效果进行调试和改进 不会的话多去尝试一下API 测试出来就好了