private void playTrack() {
    try {
      synchronized (this) {
        speaking = playListManager.getTrackDatabase().isRoboJockEnabled();
        // If a next track has been chosen by the user, use that, otherwise
        // pick one intelligently.
        currentTrack = nextTrack != null ? nextTrack : playListManager.chooseTrack();
        toKeepPlaying = true;
        nextTrack = null;
      }

      if (currentTrack != null) {
        notifyUpdateListeners();
        File file = currentTrack.getFile();
        if (file.exists()) {
          if (speaking) {
            try {
              speech.say(
                  (currentTrack.isRated() ? "" : "Unrated. ")
                      + currentTrack.getTitle()
                      + " by "
                      + currentTrack.getArtist());
            } catch (Exception e) {
              e.printStackTrace();
            } finally {
              speaking = false;
            }
          }
          if (toKeepPlaying) {
            playFile(file);
            if (toKeepPlaying) {
              currentTrack.incNoOfTimesPlayed();
              playListManager.getTrackDatabase().incNoOfPlays();
            }
          }
        } else speaking = false;
      }
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        sleep(500);
      } catch (InterruptedException e) {
      }
    }
  }
 private void playFile(File file) throws Exception {
   player = playerList.getPlayer(playListManager.getTrackDatabase().getPlayer());
   try {
     player.play(file);
   } catch (PlayerException e) {
     e.printStackTrace();
   } finally {
     // Without this, RoboJock can't talk because it fights with the
     // Java player over the sound device.
     player.close();
   }
 }