💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## uni.getRecorderManager() 获取全局唯一的录音管理器 recorderManager。 **recorderManager 对象的方法列表** ![](https://box.kancloud.cn/bbd88b8dd42075d0f55982f318f9d123_857x404.png) **start(options) 说明** ![](https://box.kancloud.cn/670c90878bd8fbf5542fe330e95f6fbf_860x348.png) 其中,采样率和码率有一定要求,具体有效值如下: ![](https://box.kancloud.cn/99c7742bea046587836e3297599753b8_859x401.png) **onStop(callback) 回调结果说明** ![](https://box.kancloud.cn/865eae2eb41bf280f19761e0ac2f5da8_864x92.png) onFrameRecorded(callback) 回调结果说明 ![](https://box.kancloud.cn/8eae000bc69c6fc0a42c69bebfa56217_860x128.png) onError(callback) 回调结果说明 ![](https://box.kancloud.cn/cae09db7bec4fb27a8cd8c79cfd145e1_862x89.png) **示例** ``` <template> <view> <button @tap="startRecord">开始录音</button> <button @tap="endRecord">停止录音</button> <button @tap="playVoice">播放录音</button> </view> </template> const recorderManager = uni.getRecorderManager(); const innerAudioContext = uni.createInnerAudioContext(); innerAudioContext.autoplay = true; export default { data: { 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(); } } } } ```