use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class BTDownloadMediatorAdvancedMenuFactory method createAddToPlaylistSubMenu.
public static SkinMenu createAddToPlaylistSubMenu() {
BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();
if (downloaders.length == 0) {
return null;
}
for (BTDownload dler : downloaders) {
if (!dler.isCompleted()) {
return null;
}
File saveLocation = dler.getSaveLocation();
if (saveLocation.isDirectory()) {
// If the file(s) is(are) inside a folder
if (!LibraryUtils.directoryContainsAudio(saveLocation)) {
return null;
}
} else if (!MediaPlayer.isPlayableFile(saveLocation)) {
return null;
}
}
SkinMenu menu = new SkinMenu(I18n.tr("Add to playlist"));
menu.add(new SkinMenuItem(new CreateNewPlaylistAction()));
Library library = LibraryMediator.getLibrary();
List<Playlist> playlists = library.getPlaylists();
if (playlists.size() > 0) {
menu.addSeparator();
for (Playlist playlist : library.getPlaylists()) {
menu.add(new SkinMenuItem(new AddToPlaylistAction(playlist)));
}
}
return menu;
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class LibraryDatabase method setupPlaylistIndexes.
private void setupPlaylistIndexes(final Connection connection) {
// add new column
update(connection, "ALTER TABLE PlaylistItems ADD sortIndex INTEGER");
// set initial playlist indexes
List<Playlist> playlists = PlaylistDB.getPlaylists(this);
for (Playlist playlist : playlists) {
List<PlaylistItem> items = playlist.getItems();
for (int i = 0; i < items.size(); i++) {
PlaylistItem item = items.get(i);
// set initial sort index (1-based)
item.setSortIndexByTrackNumber(i + 1);
item.save();
}
}
}
use of com.frostwire.alexandria.Playlist in project frostwire by frostwire.
the class PlaylistDB method getStarredPlaylist.
public static Playlist getStarredPlaylist(LibraryDatabase db) {
String query = "SELECT playlistItemId, filePath, fileName, fileSize, fileExtension, trackTitle, trackDurationInSecs, trackArtist, trackAlbum, coverArtPath, trackBitrate, trackComment, trackGenre, trackNumber, trackYear, starred " + "FROM PlaylistItems WHERE starred = ?";
List<List<Object>> result = db.query(query, true);
Playlist playlist = new Playlist(db, LibraryDatabase.STARRED_PLAYLIST_ID, LibraryDatabase.STARRED_TABLE_NAME_DO_NOT_TRANSLATE_THIS, LibraryDatabase.STARRED_TABLE_NAME_DO_NOT_TRANSLATE_THIS);
List<PlaylistItem> items = new ArrayList<>(result.size());
Set<String> paths = new HashSet<>();
for (List<Object> row : result) {
PlaylistItem item = new PlaylistItem(playlist);
PlaylistItemDB.fill(row, item);
if (!paths.contains(item.getFilePath())) {
items.add(item);
paths.add(item.getFilePath());
}
}
playlist.getItems().addAll(items);
return playlist;
}
Aggregations