use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryUtils method createNewPlaylist.
static void createNewPlaylist(final File[] files, final boolean starred) {
final DialogFinishedListener listener = new DialogFinishedListener() {
@Override
public void onDialogCancelled() {
}
@Override
public void onDialogOk(String playlistName) {
if (StringUtils.isNullOrEmpty(playlistName, true)) {
return;
}
if (playlistName.length() > 0) {
GUIMediator.instance().setWindow(GUIMediator.Tabs.LIBRARY);
final Playlist playlist = LibraryMediator.getLibrary().newPlaylist(playlistName, playlistName);
playlist.save();
GUIMediator.safeInvokeLater(new Runnable() {
@Override
public void run() {
LibraryMediator.instance().getLibraryPlaylists().addPlaylist(playlist);
LibraryMediator.instance().getLibraryPlaylists().markBeginImport(playlist);
}
});
Thread t = new Thread(new Runnable() {
public void run() {
try {
Set<File> ignore = TorrentUtil.getIgnorableFiles();
addToPlaylist(playlist, files, starred, ignore);
playlist.save();
} finally {
asyncAddToPlaylistFinalizer(playlist);
}
}
}, "createNewPlaylist");
t.setDaemon(true);
t.start();
UXStats.instance().log(UXAction.LIBRARY_PLAYLIST_CREATED);
}
}
};
GUIMediator.safeInvokeAndWait(new Runnable() {
@Override
public void run() {
File[] mediaFiles = files;
if (files.length == 1 && files[0].isDirectory()) {
mediaFiles = FileUtils.getFilesRecursive(files[0], null);
}
FrostwireInputDialog.showInputDialog(GUIMediator.getAppFrame(), I18n.tr("Playlist name"), I18n.tr("Playlist name"), GUIMediator.getThemeImage("playlist"), suggestPlaylistName(mediaFiles), listener);
}
});
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryMediator method selectCurrentMedia.
public void selectCurrentMedia() {
// Select current playlist.
Playlist currentPlaylist = MediaPlayer.instance().getCurrentPlaylist();
final MediaSource currentMedia = MediaPlayer.instance().getCurrentMedia();
// If the current song is being played from a playlist.
if (currentPlaylist != null && currentMedia != null && currentMedia.getPlaylistItem() != null) {
if (currentPlaylist.getId() != LibraryDatabase.STARRED_PLAYLIST_ID) {
// select the song once it's available on the right hand side
getLibraryPlaylists().enqueueRunnable(new Runnable() {
public void run() {
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryPlaylistsTableMediator.instance().setItemSelected(currentMedia.getPlaylistItem());
}
});
}
});
// select the playlist
getLibraryPlaylists().selectPlaylist(currentPlaylist);
} else {
LibraryExplorer libraryFiles = getLibraryExplorer();
// select the song once it's available on the right hand side
libraryFiles.enqueueRunnable(new Runnable() {
public void run() {
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryPlaylistsTableMediator.instance().setItemSelected(currentMedia.getPlaylistItem());
}
});
}
});
libraryFiles.selectStarred();
}
} else if (currentMedia != null && currentMedia.getFile() != null) {
// selects the audio node at the top
LibraryExplorer libraryFiles = getLibraryExplorer();
// select the song once it's available on the right hand side
libraryFiles.enqueueRunnable(new Runnable() {
public void run() {
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryFilesTableMediator.instance().setFileSelected(currentMedia.getFile());
}
});
}
});
libraryFiles.selectAudio();
}
// Scroll to current song.
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryPlaylists method setupModel.
private void setupModel() {
model = new DefaultListModel<>();
newPlaylistCell = new LibraryPlaylistsListCell(I18n.tr("New Playlist"), I18n.tr("Creates a new Playlist"), GUIMediator.getThemeImage("playlist_plus"), null, null);
Library library = LibraryMediator.getLibrary();
selectedPlaylistAction = new SelectedPlaylistActionListener();
Playlist starredPlaylist = LibraryMediator.getLibrary().getStarredPlaylist();
starredPlaylistCell = new LibraryPlaylistsListCell(I18n.tr("Starred"), I18n.tr("Show all starred items"), GUIMediator.getThemeImage("star_on"), starredPlaylist, selectedPlaylistAction);
model.addElement(newPlaylistCell);
model.addElement(starredPlaylistCell);
for (Playlist playlist : library.getPlaylists()) {
LibraryPlaylistsListCell cell = new LibraryPlaylistsListCell(null, null, GUIMediator.getThemeImage("playlist"), playlist, selectedPlaylistAction);
model.addElement(cell);
}
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryPlaylists method refreshSelection.
void refreshSelection() {
LibraryPlaylistsListCell cell = (LibraryPlaylistsListCell) list.getSelectedValue();
if (cell == null) {
// handle special case
if (model.getSize() == 2 && MediaPlayer.instance().getCurrentPlaylist() == null) {
list.setSelectedIndex(1);
}
return;
}
Playlist playlist = cell.getPlaylist();
if (playlist != null) {
if (playlist.getId() == LibraryDatabase.STARRED_PLAYLIST_ID) {
playlist = LibraryMediator.getLibrary().getStarredPlaylist();
} else {
playlist.refresh();
}
LibraryMediator.instance().updateTableItems(playlist);
LibraryMediator.instance().getLibrarySearch().setStatus("");
}
executePendingRunnables();
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryPlaylists method actionStartRename.
private void actionStartRename() {
cancelEdit();
int index = list.getSelectedIndex();
Playlist playlist = ((LibraryPlaylistsListCell) list.getSelectedValue()).getPlaylist();
if (playlist != null && playlist.getId() == LibraryDatabase.STARRED_PLAYLIST_ID) {
return;
}
if (index != -1) {
startEdit(index);
}
}
Aggregations