AndroidAudioRenderer : propperly set the looping value on media player

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9323 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 13 years ago
parent ac59c1ffdf
commit 1c92f500eb
  1. 13
      engine/src/android/com/jme3/audio/android/AndroidAudioRenderer.java

@ -295,8 +295,10 @@ public class AndroidAudioRenderer implements AudioRenderer,
@Override @Override
public void onCompletion(MediaPlayer mp) { public void onCompletion(MediaPlayer mp) {
if (mp.isPlaying()) {
mp.seekTo(0); mp.seekTo(0);
mp.stop(); mp.stop();
}
// XXX: This has bad performance -> maybe change overall structure of // XXX: This has bad performance -> maybe change overall structure of
// mediaplayer in this audiorenderer? // mediaplayer in this audiorenderer?
for (AudioNode src : musicPlaying.keySet()) { for (AudioNode src : musicPlaying.keySet()) {
@ -305,6 +307,7 @@ public class AndroidAudioRenderer implements AudioRenderer,
break; break;
} }
} }
} }
/** /**
@ -342,9 +345,15 @@ public class AndroidAudioRenderer implements AudioRenderer,
if (channel == 0) { if (channel == 0) {
soundpoolStillLoading.put(audioData.getId(), src); soundpoolStillLoading.put(audioData.getId(), src);
} else { } else {
if (src.getStatus() != Status.Stopped) {
soundPool.stop(channel);
src.setStatus(Status.Stopped);
}
src.setChannel(channel); // receive a channel at the last src.setChannel(channel); // receive a channel at the last
setSourceParams(src); setSourceParams(src);
// playing at least // playing at least
} }
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.SEVERE, logger.log(Level.SEVERE,
@ -402,7 +411,7 @@ public class AndroidAudioRenderer implements AudioRenderer,
src.setStatus(Status.Playing); src.setStatus(Status.Playing);
musicPlaying.put(src, mp); musicPlaying.put(src, mp);
mp.start(); mp.start();
}else{ } else {
mp.start(); mp.start();
} }
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
@ -413,7 +422,7 @@ public class AndroidAudioRenderer implements AudioRenderer,
} }
private void setSourceParams(AudioNode src, MediaPlayer mp) { private void setSourceParams(AudioNode src, MediaPlayer mp) {
mp.setLooping(true); mp.setLooping(src.isLooping());
mp.setVolume(src.getVolume(), src.getVolume()); mp.setVolume(src.getVolume(), src.getVolume());
//src.getDryFilter(); //src.getDryFilter();
} }

Loading…
Cancel
Save