d***@163.com
d***@163.com
  • 发布:2024-06-18 16:32
  • 更新:2024-06-20 16:55
  • 阅读:175

app频繁崩溃咨询

分类:HBuilderX

使用uniapp的uni统计,后台有很多崩溃记录。报错信息如下,求助:是什么原因导致的。
java.lang.IllegalStateException at android.media.MediaPlayer._start(Native Method) at android.media.MediaPlayer.startImpl(MediaPlayer.java:1336) at android.media.MediaPlayer.start(MediaPlayer.java:1311) at io.dcloud.feature.audio.AudioPlayer.startPlay(Unknown Source:3) at io.dcloud.feature.audio.AudioPlayer.execEvents(Unknown Source:10) at io.dcloud.feature.audio.AudioPlayer$2.onPrepared(Unknown Source:1) at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:3347) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.os.HandlerThread.run(HandlerThread.java:67)

因不太看得懂错误提示,怀疑是createInnerAudioContext的报错。同一个页面中,会有多次调用此函数的情况。
使用createInnerAudioContext的代码片段如下:

export const playAudio = (context, src, callback) => {  
    console.log("src", src);  
    if (context) {  
        context.destroy();  
    }  
    context = uni.createInnerAudioContext();  
    context.src = src;  
    context.play();  
    context.onPlay(() => {  
        console.log("开始播放");  
        callback(1);  
    });  
    context.onEnded(() => {  
        console.log("播放结束")  
        callback(2);  
    })  
}
2024-06-18 16:32 负责人:无 分享
已邀请:

要回复问题请先登录注册