synchronized void setCurrentPlaying(int currentPlayingIndex) { try { setCurrentPlaying(downloadList.get(currentPlayingIndex)); } catch (IndexOutOfBoundsException x) { // Ignored } }
private synchronized void play(int index, boolean start) { if (index < 0 || index >= size()) { reset(); setCurrentPlaying(null); } else { setCurrentPlaying(index); checkDownloads(); if (start) { if (jukeboxEnabled) { jukeboxService.skip(getCurrentPlayingIndex(), 0); setPlayerState(STARTED); } else { bufferAndPlay(); } } } }
@Override public synchronized void remove(DownloadFile downloadFile) { if (downloadFile == currentDownloading) { currentDownloading.cancelDownload(); currentDownloading = null; } if (downloadFile == currentPlaying) { reset(); setCurrentPlaying(null); } downloadList.remove(downloadFile); revision++; lifecycleSupport.serializeDownloadQueue(); updateJukeboxPlaylist(); }
public synchronized void clear(boolean serialize) { reset(); downloadList.clear(); revision++; if (currentDownloading != null) { currentDownloading.cancelDownload(); currentDownloading = null; } setCurrentPlaying(null); if (serialize) { lifecycleSupport.serializeDownloadQueue(); } updateJukeboxPlaylist(); }