public String playSong(int index) { if (!SOUND_ON) { return null; // don't play anything if the SOUND_ON is off } if (!timer.isRunning()) { timer.start(); } for (int i = index; i >= 0; i--) { // count down to find last valid track if (TITLES.containsKey(i)) { index = i; break; } } String title = "mix/" + TITLES.get(index); if (mp3 != null) { mp3.kill(); } else { timer.start(); } mp3 = new MP3(title); new Thread(mp3).start(); return ("Now playing: " + TITLES.get(index)); }
public void stopSong() { if (mp3 != null) { mp3.kill(); } playing = false; }