银狼
银狼
  • 发布:2025-11-10 19:10
  • 更新:2025-11-10 19:13
  • 阅读:16

【报Bug】微信小程序 纯血鸿蒙系统 录音无效

分类:鸿蒙Next

产品分类: uniapp/小程序/微信

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 11

HBuilderX类型: Alpha

HBuilderX版本号: 4.84

第三方开发者工具版本号: Stable 1.06.2504060

基础库版本号: 3.2.4

项目创建方式: HBuilderX

App下载地址或H5⽹址: 微信里边搜索 农千问 小程序

操作步骤:

正常点击开始录音

预期结果:

点击开始录音正常录音,onStart也会正常监听,预期结果和安卓和IOS小程序正常运行一致

实际结果:

点击开始录音无反应,onStart监听不执行无反应

bug描述:

uni.getRecorderManager()录音功能 在安卓系统、IOS系统的微信小程序里边正常,在纯血鸿蒙的微信小程序里边无效 监听onStart也无反应。
纯血鸿蒙手机型号:nova 12 Pro, 系统: Harmony OS 5.1.0.

<template>  
  <view>  
        <button @tap="startRecord">开始录音</button>  
        <button @tap="endRecord">停止录音</button>  
        <button @tap="playVoice">播放录音</button>  
  </view>  
</template>  

<script>  
    const recorderManager = uni.getRecorderManager();  
    const innerAudioContext = uni.createInnerAudioContext();  

    innerAudioContext.autoplay = true;  

    export default {  
        data() {  
            return {  
                text: 'uni-app',  
                voicePath: ''  
            }  
        },  
        onLoad() {  
            let self = this;  
            self.initRecord()  
        },  
        methods: {  
            startRecord() {  
                console.log('开始录音');  

                recorderManager.start();  
            },  
            endRecord() {  
                console.log('录音结束');  
                recorderManager.stop();  
            },  
            playVoice() {  
                console.log('播放录音');  

                if (this.voicePath) {  
                    innerAudioContext.src = this.voicePath;  
                    innerAudioContext.play();  
                }  
            },  
            /**  
               * 初始化语音识别回调    
               * 绑定语音播放开始事件    
             */  
            initRecord() {  
              let that = this;  
              recorderManager.onStart(function (res) {  
                console.log('录音开始')  
              });  
              // 录制语音  
              recorderManager.onStop(async function (res) {  
                    try {  
                        console.log('recorder stop' + JSON.stringify(res));  
                        that.voicePath = res.tempFilePath;  
                    } catch (error) {  
                        console.error('获取音频时长失败:', error);  
                    }  
              });  

            },  

        }  

}  
</script>
2025-11-10 19:10 负责人:无 分享
已邀请:
DCloud_UNI_JBB

DCloud_UNI_JBB

试试原生微信小程序有没有这个问题

  • 银狼 (作者)

    他原生好像鸿蒙就没支持,这种情况怎么办?

    2025-11-10 19:27

  • DCloud_UNI_JBB

    回复 银狼: 只能等微信兼容,可以先在微信社区里反馈下这个问题

    2025-11-10 19:29

要回复问题请先登录注册