Search in sources :

Example 16 with Playlist

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;
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) Playlist(com.frostwire.alexandria.Playlist) SkinMenu(com.frostwire.gui.theme.SkinMenu) CreateNewPlaylistAction(com.frostwire.gui.bittorrent.BTDownloadActions.CreateNewPlaylistAction) AddToPlaylistAction(com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction) Library(com.frostwire.alexandria.Library) File(java.io.File)

Example 17 with Playlist

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();
        }
    }
}
Also used : Playlist(com.frostwire.alexandria.Playlist) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 18 with Playlist

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;
}
Also used : Playlist(com.frostwire.alexandria.Playlist) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) PlaylistItem(com.frostwire.alexandria.PlaylistItem) HashSet(java.util.HashSet)

Aggregations

Playlist (com.frostwire.alexandria.Playlist)18 Library (com.frostwire.alexandria.Library)4 PlaylistItem (com.frostwire.alexandria.PlaylistItem)3 DialogFinishedListener (com.frostwire.gui.theme.DialogFinishedListener)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 SkinMenu (com.frostwire.gui.theme.SkinMenu)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)2 File (java.io.File)2 AddToPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction)1 CreateNewPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.CreateNewPlaylistAction)1 MediaSource (com.frostwire.gui.player.MediaSource)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 Transferable (java.awt.datatransfer.Transferable)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1