更新记录
1.0.0(2026-02-10)
平台兼容性
uni-app(4.87)
| Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
Android插件版本 |
iOS |
鸿蒙 |
| - |
- |
- |
- |
- |
- |
7.0 |
1.0.0 |
- |
- |
| 微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
小红书小程序 |
快应用-华为 |
快应用-联盟 |
| - |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
uni-app x(4.87)
| Chrome |
Safari |
Android |
Android插件版本 |
iOS |
鸿蒙 |
微信小程序 |
| - |
- |
7.0 |
1.0.0 |
- |
- |
- |
xwq-micrecorder
开发文档
插件说明
- 实时PCM回调
- 实时录音回调
- 后台录音
- 暂支持安卓端,IOS/鸿蒙端开发中...
初始化参数说明
| 名称 |
是否必填 |
说明 |
| recorderRate |
Y |
采样率,默认44100 |
| time |
Y |
录制时长 |
| saveFilePath |
Y |
保存录制文件地址 |
uniappX中使用
<template>
<view>
<button @click="start">开始录音</button>
<button @click="stop">停止录音</button>
<button @click="pcmToBase64">PCM转base64</button>
<button @click="pcmToWav">pcm转Wav</button>
<button @click="removeAllLocaltempFile">删除缓存文件</button>
</view>
</template>
<script setup>
import { startRecord,stopRecord,fileToBase64,pcmToWav,getAppFileDir,deleteAllFiles } from '@/uni_modules/xwq-micrecorder';
import { RecorderOption } from "@/uni_modules/xwq-micrecorder/utssdk/interface.uts";
const recorderPath=ref("")
/**
* 开始录音
*/
const start=()=>{
startRecord({
recorderRate:16000, //采样率:16kHz
time:10000, //录制时间,单位毫秒
success:(path:string)=>{
console.log('录制音频保存地址===',path)
recorderPath.value=path
}
} as RecorderOption)
}
/**
* 停止录音
*/
const stop=()=>{
stopRecord()
}
/**
* pcm转base64
*/
const pcmToBase64=()=>{
const base64Result=fileToBase64(recorderPath.value)
// console.log('base64Result===',base64Result)
}
/**
* pcm转wav
*/
const pcmToWav=()=>{
const wavResult=pcmToWav(recorderPath.value)
console.log('wavResult===',wavResult)
}
/**
* 删除所有缓存的录音文件
*/
const removeAllLocaltempFile=()=>{
const fileDir=getAppFileDir()
console.log('fileDir===',fileDir)
deleteAllFiles(fileDir)
}
</script>
<style>
</style>
uniapp中使用
<template>
<view>
<button @click="start">开始录音</button>
<button @click="stop">停止录音</button>
<button @click="pcmToBase64">PCM转base64</button>
<button @click="pcmToWav">pcm转Wav</button>
<button @click="removeAllLocaltempFile">删除缓存文件</button>
</view>
</template>
<script setup>
import { startRecord,stopRecord,fileToBase64,pcmToWav,getAppFileDir,deleteAllFiles } from '@/uni_modules/xwq-micrecorder';
const recorderPath=ref("")
/**
* 开始录音
*/
const start=()=>{
startRecord({
recorderRate:16000, //采样率:16kHz
time:10000, //录制时间,单位毫秒
success:(path)=>{
console.log('录制音频保存地址===',path)
recorderPath.value=path
}
})
}
/**
* 停止录音
*/
const stop=()=>{
stopRecord()
}
/**
* pcm转base64
*/
const pcmToBase64=()=>{
const base64Result=fileToBase64(recorderPath.value)
// console.log('base64Result===',base64Result)
}
/**
* pcm转wav
*/
const pcmToWav=()=>{
const wavResult=pcmToWav(recorderPath.value)
console.log('wavResult===',wavResult)
}
/**
* 删除所有缓存的录音文件
*/
const removeAllLocaltempFile=()=>{
const fileDir=getAppFileDir()
console.log('fileDir===',fileDir)
deleteAllFiles(fileDir)
}
</script>
<style>
</style>