Closed alienfractal closed 5 years ago
I'm trying to handle the exception here but it just keeps crashing randomly.
void playSound(String nextfile) async {
print("PLAYING: " + nextfile);
Future<AudioPlayer> future = Flame.audio.play(nextfile, volume: 0.4);
future.then((AudioPlayer onValue) {
print("playerId: " + onValue.playerId +" State: "+onValue.state.toString() +" ");
onValue.onPlayerError.handleError((e) => print("AudioController onValue.onPlayerError :"+e));
// Invoked when the future is completed with a value.
return onValue;
}, onError: (e) {
// Invoked when the future is completed with an error.
return Future.value(null);
});
}
Created my own class with a static AudioCache instance and the issue is gone, not sure if it's a problem with the Flame method that calls audio play.
static AudioCache _player;
I will just close this issue and contact Flame devs.
I'm trying to play a sound each time an object get's destroyed in a space shooter using FLAME and FLutter and some times the application just crashes in this point.
I'm unable to catch exception as it just crashes the app no matter if i wrap the call in a try catch.
W/MediaAnalyticsItem(17316): Unable to record: (codec:0:-1:-11:0:6:android.media.mediacodec.mime=audio/mpeg:android.media.mediacodec.mode=audio:android.media.mediacodec.encoder=0:android.media.mediacodec.codec=OMX.MTK.AUDIO.DECODER.MP3:android.media.mediacodec.secure=0:android.media.mediacodec.bytesin=6432:) [forcenew=0] V/NuMediaExtractor(17316): setDataSource fd=239 (/data/data/com.example.galaxygame/cache/ufo_explosion0.mp3), offset=0, length=5289 D/AndroidRuntime(17316): Shutting down VM E/AndroidRuntime(17316): FATAL EXCEPTION: main E/AndroidRuntime(17316): Process: com.example.galaxygame, PID: 17316 E/AndroidRuntime(17316): java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference E/AndroidRuntime(17316): at xyz.luan.audioplayers.WrappedSoundPool.onLoadComplete(WrappedSoundPool.java:182) E/AndroidRuntime(17316): at android.media.SoundPool$EventHandler.handleMessage(SoundPool.java:551) E/AndroidRuntime(17316): at android.os.Handler.dispatchMessage(Handler.java:106) E/AndroidRuntime(17316): at android.os.Looper.loop(Looper.java:164) E/AndroidRuntime(17316): at android.app.ActivityThread.main(ActivityThread.java:6641) E/AndroidRuntime(17316): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(17316): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:583) E/AndroidRuntime(17316): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870) I/OMXClient(17316): Treble IOmx obtained W/MediaAnalyticsItem(17316): Unable to record: (codec:0:-1:-11:0:6:android.media.mediacodec.mime=audio/mpeg:android.media.mediacodec.mode=audio:android.media.mediacodec.encoder=0:android.media.mediacodec.codec=OMX.MTK.AUDIO.DECODER.MP3:android.media.mediacodec.secure=0:android.media.mediacodec.bytesin=4872:) [forcenew=0] Lost connection to device. Exited (sigterm)
https://github.com/luanpotter/audioplayers/blob/b371975fac5e67ce0a7c4d2d120d2d2211ccd219/android/src/main/java/xyz/luan/audioplayers/WrappedSoundPool.java#L183
ANy advice or clarification what this means will be much appreciated.