Ejemplo n.º 1
0
  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) {
      }
    }
  }
Ejemplo n.º 2
0
 public float getProbability(Track track) {
   if (track.getFile() == null) return 0;
   return track.getProbability();
 }