From e8512b3ed53d2d04d2b85ac37b50ed54e528bf7d Mon Sep 17 00:00:00 2001 From: BlackMinou Date: Mon, 14 Sep 2015 10:02:25 +0200 Subject: [PATCH] android/audio: fix multiple music playing when pausing app Signed-off-by: BlackMinou --- lib/android/audio.nit | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/android/audio.nit b/lib/android/audio.nit index b361b4f..40c69c2 100644 --- a/lib/android/audio.nit +++ b/lib/android/audio.nit @@ -377,6 +377,16 @@ class MediaPlayer # Load a sound for a given resource id fun load_sound(id: Int, context: NativeActivity): Music do + # FIXME: maybe find a better way to handle this situation + # If two different music are loaded with the same `MediaPlayer`, + # a new `NativeMediaPlayer` will be created for the secondd music + # and the nit program will loose the handle to the previous one + # If the previous music is playing, we need to stop it + if playing then + stop + reset + destroy + end self.nmedia_player = self.nmedia_player.create(context, id) if self.nmedia_player.is_java_null then self.error = new Error("Failed to load a sound") -- 1.7.9.5