android录音程序闪退,【报Bug】调用录音时,app闪退了

在华为nova4e手机上,使用MAR-AL00型号并运行安卓9系统时,通过调用录音API进行操作导致应用程序崩溃,而同样的代码在小米手机上则能正常工作。问题可能与设备特定的兼容性或权限设置有关。代码示例展示了录音和播放的实现过程,包括录音管理器和内部音频上下文的使用。在录音停止时,会获取临时文件路径,并在播放结束时触发事件。解决方案可能需要针对华为设备进行适配或错误处理优化。
摘要由CSDN通过智能技术生成

今天在华为nova 4e 型号MAR-AL00 安卓9版本测试, 调用录音api时,app闪退了,但是在小米手机测试,不会出现,使用的老模板模式编译模式,代码如下:

语音描述(录音时长最大为10分钟)

删除录音

{{

isRecord === 0?'点击录制':'录制中'

}}

{{

timing+(isRecord == 2?' 点击播放':' 正在播放')

}}

const soundRecords = uni.getRecorderManager();

const innerAudioContext = uni.createInnerAudioContext();

innerAudioContext.autoplay = true;

let timer = null;

let minutes = 0;

let seconds = 0;

import { mapGetters } from 'vuex';

export default {

data() {

return {

timing: '0分0秒',

text: '',

isRecord: 0,

iconPath: '../../static/record/startrecord@3x.png',

voicePath: '',

time: 0,

isPlay: false

};

},

computed: {

...mapGetters(['getToken'])

},

mounted() {

console.log("1111")

},

onLoad() {

// this.$http.gettonken(this.getToken);

},

watch: {

"voicePath"(newValue) {

if(newValue){

console.log(this.time);

console.log(this.voicePath);

let voice = {

voicePath: newValue,

time: this.time

}

this.$emit("input",voice)

}

}

},

mounted(){

soundRecords.onStop(res => {

console.log(this.time);

clearTimeout(timer);

if(res.tempFilePath){

this.voicePath = res.tempFilePath

console.log(this.voicePath);

}else{

console.log("这里测试是否为空");

}

console.log('res: ' + JSON.stringify(res));

});

innerAudioContext.onEnded(() => {

this.isRecord = 2;

this.iconPath = '../../static/record/startplay@3x.png';

this.isPlay = false;

// this.timing = `0分0秒`;

});

},

methods: {

catchMove(){

return ;

},

onDeleteTap() {

this.voicePath = '';

this.timing = '0分0秒';

this.isRecord = 0;

minutes = 0;

seconds = 0;

this.isPlay = false;

this.iconPath= '../../static/record/startrecord@3x.png'

this.$modal({

title: "提示",

content: "删除成功",

showCancel: false

})

},

onToggleRecordStatusTap() {

switch (this.isRecord) {

case 0:

this.onStartRecordTap();

this.iconPath = '../../static/record/stoprecord@3x.png';

break;

case 1:

this.onStopRecordTap();

this.iconPath = '../../static/record/startplay@3x.png';

break;

case 2:

if(!this.isPlay){

this.isPlay = true;

this.onPlayRecordTap();

this.iconPath = '../../static/record/stopplay@3x.png';

}else{

this.toast("正在播放,请勿重复点击")

}

break;

}

},

onStartRecordTap() {

console.log('1: ');

soundRecords.start({

format: 'mp3'

});

this.isRecord = 1;

this.getTiming();

},

getTiming() {

if (this.isRecord == 1) {

if (minutes == 10 && seconds == 0) {

clearTimeout(timer);

minutes = 0;

seconds = 0;

} else {

this.time +=1;

console.log(this.time);

if (seconds == 59) {

seconds = 0;

minutes += 1;

} else {

seconds += 1;

}

this.timing = `${this.formatFull(minutes)}分${this.formatFull(seconds)}秒`;

timer = setTimeout(() => {

console.log(11);

this.getTiming();

}, 1000);

}

}

},

onStopRecordTap() {

soundRecords.stop();

console.log(this.time);

this.isRecord = 2;

},

onPlayRecordTap() {

if(this.isPlay){

this.toast("正在播放,请勿重复点击")

return ;

}

this.isPlay = true;

if (this.voicePath) {

// this.isRecord = 3;

innerAudioContext.src = this.voicePath;

innerAudioContext.onPlay(() => {

console.log('开始播放');

});

}else{

console.log('res: ' + this.voicePath);

}

}

}

};

.record-index {

height: 200upx;

width: 100%;

background: #ffffff;

}

/* .billow{

width: 6upx;

height: 16upx;

display: inline-block;

background: #66CC99;

position: absolute;top: 50%;transform: translateY(-50%);

animation: play 1.8s linear infinite;

border-radius: 3upx;

}

.billow1{

height: 20upx;

animation-delay: .8s;

}

.billow2{

height: 56upx;

animation-delay: 1s;

}

.billow3{

height: 50upx;

animation-delay: 1.2s;

}

.billow4{

height: 40upx;

animation-delay: 1.4s;

}

.billow5{

height: 30upx;

animation-delay: 1.6s;

}

.billow6{

height: 16upx;

animation-delay: 1.8s;

}

@keyframes play{

0% {

height: 20upx;

}

16% {

height: 56upx;

}

32% {

height: 50upx;

}

48% {

height: 40upx;

}

54% {

height: 30upx;

}

80% {

height: 16upx;

}

100% {

height: 20upx;

}

} */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值