Search in sources :

Example 21 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class LibraryMediator method addItemsToLibraryTable.

void addItemsToLibraryTable(List<PlaylistItem> items) {
    for (PlaylistItem item : items) {
        LibraryPlaylistsTableMediator.instance().add(item);
    }
    LibraryPlaylistsTableMediator.instance().getTable().repaint();
    getLibrarySearch().addResults(items.size());
}
Also used : PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 22 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class LibraryPlaylists method saveM3U.

/**
 * Handles actually copying and writing the playlist to disk.
 * @param path - file location to save the list to
 */
private void saveM3U(final Playlist playlist, final String path) {
    BackgroundExecutorService.schedule(new Runnable() {

        public void run() {
            try {
                List<File> files = new ArrayList<>();
                List<PlaylistItem> items = playlist.getItems();
                for (PlaylistItem item : items) {
                    File file = new File(item.getFilePath());
                    if (file.exists()) {
                        files.add(file);
                    }
                }
                M3UPlaylist.save(path, files);
            } catch (Exception e) {
                e.printStackTrace();
                GUIMediator.safeInvokeLater(new Runnable() {

                    public void run() {
                        GUIMediator.showError("Unable to save playlist");
                    }
                });
            }
        }
    });
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) PlaylistItem(com.frostwire.alexandria.PlaylistItem) IOException(java.io.IOException)

Example 23 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class MediaPlayer method isThisBeingPlayed.

public boolean isThisBeingPlayed(File file) {
    if (isPlayerStoppedClosedFailed()) {
        return false;
    }
    MediaSource currentMedia = getCurrentMedia();
    if (currentMedia == null) {
        return false;
    }
    File currentMediaFile = currentMedia.getFile();
    if (currentMediaFile != null && file.equals(currentMediaFile))
        return true;
    PlaylistItem playlistItem = currentMedia.getPlaylistItem();
    return playlistItem != null && new File(playlistItem.getFilePath()).equals(file);
}
Also used : RandomAccessFile(java.io.RandomAccessFile) IsoFile(com.frostwire.mp4.IsoFile) File(java.io.File) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 24 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem in project frostwire by frostwire.

the class MediaPlayerComponent method updateTitle.

private void updateTitle(MediaSource mediaSource) {
    try {
        if (mediaSource == null) {
            return;
        }
        // update controls
        MediaSource currentMedia = mediaSource;
        updateShareButtonVisibility(currentMedia);
        PlaylistItem playlistItem = currentMedia.getPlaylistItem();
        String currentText = null;
        if (currentMedia != null && currentMedia instanceof StreamMediaSource) {
            currentText = ((StreamMediaSource) currentMedia).getTitle();
        } else if (playlistItem != null) {
            // Playing from Playlist.
            String artistName = playlistItem.getTrackArtist();
            String songTitle = playlistItem.getTrackTitle();
            String albumToolTip = (playlistItem.getTrackAlbum() != null && playlistItem.getTrackAlbum().length() > 0) ? " - " + playlistItem.getTrackAlbum() : "";
            String yearToolTip = (playlistItem.getTrackYear() != null && playlistItem.getTrackYear().length() > 0) ? " (" + playlistItem.getTrackYear() + ")" : "";
            currentText = artistName + " - " + songTitle;
            trackTitle.setToolTipText(artistName + " - " + songTitle + albumToolTip + yearToolTip);
        } else if (currentMedia != null && currentMedia.getFile() != null) {
            // playing from Audio.
            currentText = currentMedia.getFile().getName();
            trackTitle.setToolTipText(currentMedia.getFile().getAbsolutePath());
        } else if (currentMedia != null && currentMedia.getFile() == null && currentMedia.getURL() != null) {
            // 
            // System.out.println("StreamURL: " + currentMedia.getURL().toString());
            // sString streamURL = currentMedia.getURL().toString();
            // Pattern urlStart = Pattern.compile("(http://[\\d\\.]+:\\d+).*");
            // Matcher matcher = urlStart.matcher(streamURL);
            // generic internet stream
            currentText = "internet ";
        }
        setTitleHelper(currentText);
    } catch (Throwable e) {
        LOG.error("Error doing UI updates", e);
    }
}
Also used : PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 25 with PlaylistItem

use of com.frostwire.alexandria.PlaylistItem 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)

Aggregations

PlaylistItem (com.frostwire.alexandria.PlaylistItem)28 ArrayList (java.util.ArrayList)8 File (java.io.File)7 Transferable (java.awt.datatransfer.Transferable)4 Playlist (com.frostwire.alexandria.Playlist)3 Item (com.frostwire.gui.library.LibraryPlaylistsTableTransferable.Item)3 List (java.util.List)3 TagsReader (com.frostwire.gui.library.tags.TagsReader)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)2 SkinPopupMenu (com.frostwire.gui.theme.SkinPopupMenu)2 MigLayout (net.miginfocom.swing.MigLayout)2 TagsData (com.frostwire.gui.library.tags.TagsData)1 IsoFile (com.frostwire.mp4.IsoFile)1 FileTransferable (com.limegroup.gnutella.gui.dnd.FileTransferable)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 HashSet (java.util.HashSet)1