diff --git a/framework/src/com/phonegap/AudioHandler.java b/framework/src/com/phonegap/AudioHandler.java index dc672569..6259496a 100755 --- a/framework/src/com/phonegap/AudioHandler.java +++ b/framework/src/com/phonegap/AudioHandler.java @@ -130,13 +130,9 @@ public class AudioHandler extends Plugin { * Stop all audio players and recorders. */ public void onDestroy() { - java.util.Set> s = this.players.entrySet(); - java.util.Iterator> it = s.iterator(); - while(it.hasNext()) { - Entry entry = it.next(); - AudioPlayer audio = entry.getValue(); + for (AudioPlayer audio : this.players.values()) { audio.destroy(); - } + } this.players.clear(); } @@ -154,26 +150,22 @@ public class AudioHandler extends Plugin { // If phone ringing, then pause playing if ("ringing".equals(data) || "offhook".equals(data)) { - // Get all audio players and pause then - java.util.Set> s = this.players.entrySet(); - java.util.Iterator> it = s.iterator(); - while (it.hasNext()) { - Entry entry = it.next(); - AudioPlayer audio = entry.getValue(); + // Get all audio players and pause them + for (AudioPlayer audio : this.players.values()) { if (audio.getState() == AudioPlayer.MEDIA_RUNNING) { this.pausedForPhone.add(audio); audio.pausePlaying(); } } + } // If phone idle, then resume playing those players we paused else if ("idle".equals(data)) { - for (int i=0; i(); + this.pausedForPhone.clear(); } } }