Search in sources :

Example 1 with AddToPlaylistAction

use of com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction 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)

Aggregations

Library (com.frostwire.alexandria.Library)1 Playlist (com.frostwire.alexandria.Playlist)1 AddToPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction)1 CreateNewPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.CreateNewPlaylistAction)1 SkinMenu (com.frostwire.gui.theme.SkinMenu)1 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)1 File (java.io.File)1