Exemplo n.º 1
0
  synchronized void setCurrentPlaying(DownloadFile currentPlaying) {
    this.currentPlaying = currentPlaying;

    MusicDirectory.Entry song = currentPlaying != null ? currentPlaying.getSong() : null;
    Util.broadcastNewTrackInfo(this, song);
    NotificationUtil.updateNotification(this, this, handler, song, song != null);
  }
Exemplo n.º 2
0
  @Override
  public synchronized DownloadFile forSong(MusicDirectory.Entry song) {
    for (DownloadFile downloadFile : downloadList) {
      if (downloadFile.getSong().equals(song)) {
        return downloadFile;
      }
    }

    DownloadFile downloadFile = downloadFileCache.get(song);
    if (downloadFile == null) {
      downloadFile = new DownloadFile(this, song);
      downloadFileCache.put(song, downloadFile);
    }
    return downloadFile;
  }
Exemplo n.º 3
0
 @Override
 public synchronized int getPlayerDuration() {
   if (currentPlaying != null) {
     Integer duration = currentPlaying.getSong().getDuration();
     if (duration != null) {
       return duration * 1000;
     }
   }
   if (playerState != IDLE && playerState != DOWNLOADING && playerState != PlayerState.PREPARING) {
     try {
       return mediaPlayer.getDuration();
     } catch (Exception x) {
       handleError(x);
     }
   }
   return 0;
 }
Exemplo n.º 4
0
  synchronized void setPlayerState(PlayerState playerState) {
    LOG.info(this.playerState.name() + " -> " + playerState.name() + " (" + currentPlaying + ")");

    if (playerState == PAUSED) {
      lifecycleSupport.serializeDownloadQueue();
    }

    Util.broadcastPlaybackStatusChange(this, playerState);

    this.playerState = playerState;

    if (playerState == STARTED) {
      scrobbler.scrobble(this, currentPlaying, false);
      NotificationUtil.setNotificationHiddenByUser(this, false);
    } else if (playerState == COMPLETED) {
      scrobbler.scrobble(this, currentPlaying, true);
    }

    MusicDirectory.Entry song = currentPlaying == null ? null : currentPlaying.getSong();
    NotificationUtil.updateNotification(this, this, handler, song, this.playerState == STARTED);
  }