寒冰沁狐兰
寒冰沁狐兰
  • 发布:2023-07-27 21:37
  • 更新:2023-07-27 22:00
  • 阅读:203

【报Bug】自定义底座录音闪退

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 教育版

HBuilderX类型: 正式

HBuilderX版本号: 3.8.7

手机系统: Android

手机系统版本号: Android 10

手机厂商: 小米

手机机型: Redmi k30

页面类型: vue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

示例代码:
const recorderManager = uni.getRecorderManager({  
        format:"aac", sampleRate:8000  
    })  
    const windowWidth = uni.getWindowInfo().windowWidth  
    let timer  

    const RecordActions = {  
        Cancel: 'Cancel',  
        Translate: 'Translate'  
    }  

    export default {  
        name: "",  
        components: {},  
        props: {  
            visible: Boolean,  
        },  
        data() {  
            return {  
                cancelFlag: false,  
                activeAction: null,  
                duration: 0,  
            };  
        },  
        computed: {  
            isCancelActive() {  
                return this.activeAction === RecordActions.Cancel  
            },  
            isTranslateActive() {  
                return this.activeAction === RecordActions.Translate  
            }  
        },  
        watch: {  
            visible(newVal) {  
                if (newVal) {  
                    this.recordStart()  
                }  
            }  
        },  
        methods: {  
            recordStart() {  
                recorderManager.onStop(({  
                    tempFilePath  
                }) => {  
                    if (this.isCancelActive || this.isTranslateActive) {  
                        uni.$u.toast('已取消')  
                    } else {  
                        this.$emit('recordFinish', tempFilePath, this.duration)  
                    }  
                    this.clearTimer()  
                    this.activeAction = null  
                    this.cancelFlag = false  
                })  
                recorderManager.onStart((res) => {  
                    this.startTimer()  
                })  
                recorderManager.onError((err) => {  
                    console.log(err);  
                })  
                recorderManager.start();  
            },  
            touchMoveSpeech(e, recordHeight) {  
                const touches = e.touches[0]  
                this.cancelFlag = touches.pageY < recordHeight  
                if (this.cancelFlag) {  
                    const isCancel = touches.pageX < windowWidth / 2  
                    this.activeAction = isCancel ? RecordActions.Cancel : RecordActions.Translate  
                } else {  
                    this.activeAction = null  
                }  
            },  
            checkStopType() {  
                console.log(this.activeAction);  
                recorderManager.stop()  
            },  
            startTimer() {  
                timer = setInterval(() => this.duration++, 1000);  
            },  
            clearTimer() {  
                if (timer) {  
                    clearInterval(timer)  
                    this.duration = 0  
                }  
            }  
        },  
    }

操作步骤:

自定义底座,点击录音5秒后,停止录音然后就闪退

预期结果:
recorderManager.onStop(({  
                    tempFilePath  
                }) => {  
                    if (this.isCancelActive || this.isTranslateActive) {  
                        uni.$u.toast('已取消')  
                    } else {  
                        this.$emit('recordFinish', tempFilePath, this.duration)  
                    }  
                    this.clearTimer()  
                    this.activeAction = null  
                    this.cancelFlag = false  
                })  

实际结果:

闪退

bug描述:

录音闪退

2023-07-27 21:37 负责人:无 分享
已邀请:
寒冰沁狐兰

寒冰沁狐兰 (作者)

此个引用的是空上aar文件

  • 1***@qq.com

    请问解决这个问题了吗。我也遇到同样的问题

    2024-04-24 11:10

要回复问题请先登录注册