コード例 #1
0
ファイル: MusicPlayer.java プロジェクト: manubp9/musicOrgV5
 /** Terminate the player, if there is one. */
 private void killPlayer() {
   synchronized (this) {
     if (player != null) {
       player.stop();
       player = null;
     }
   }
 }
コード例 #2
0
ファイル: MusicPlayer.java プロジェクト: manubp9/musicOrgV5
 /**
  * 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();
   }
 }
コード例 #3
0
 @Override
 public void run() {
   Thread thisThread = Thread.currentThread();
   while (playingThread == thisThread) {
     try {
       player.play();
     } catch (Exception e) {
     }
   }
 }
コード例 #4
0
  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());

    }
  }