예제 #1
0
  /**
   * Reload playlist content. <code>refresh</code> has better performance and is more server
   * friendly, use it whenever possible.
   *
   * @see #refresh(int)
   * @throws MPDServerException if an error occur while contacting server.
   * @return current playlist version.
   */
  private int refresh() throws MPDServerException {
    if (firstRefreash) {
      // TODO should be atomic
      MPDStatus status = this.mpd.getStatus();
      List<String> response = this.mpd.getMpdConnection().sendCommand(MPD_CMD_PLAYLIST_LIST);
      List<Music> playlist = Music.getMusicFromList(response, false);

      list.clear();
      list.addAll(playlist);

      lastPlaylistVersion = status.getPlaylistVersion();
      firstRefreash = false;
    } else {
      this.lastPlaylistVersion = this.refresh(lastPlaylistVersion);
    }
    return this.lastPlaylistVersion;
  }
예제 #2
0
 /**
  * Clears playlist content.
  *
  * @throws MPDServerException if an error occur while contacting server.
  */
 public void clear() throws MPDServerException {
   this.mpd.getMpdConnection().sendCommand(MPD_CMD_PLAYLIST_CLEAR);
   list.clear();
 }