/** Terminate the player, if there is one. */ private void killPlayer() { synchronized (this) { if (player != null) { player.stop(); player = null; } } }
/** * Play a part of the given file. The method returns once it has finished playing. * * @param filename The file to be played. */ public void playSample(String filename) { try { setupPlayer(filename); player.play(500); } catch (JavaLayerException e) { reportProblem(filename); } finally { killPlayer(); } }
@Override public void run() { Thread thisThread = Thread.currentThread(); while (playingThread == thisThread) { try { player.play(); } catch (Exception e) { } } }
public void stopSong() { if (isPlaying) { // playingThread.interrupt(); // isPlaying = false; //playingThread.isAlive(); //playingThread.isAlive(); // will later set from isAlive()? // playingThread = null; this.stopMyThread(); player.close(); isPlaying = false; // playingThread.isAlive(); // System.out.println(playingThread.isAlive()); } }