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());
}
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");
}
});
}
}
});
}
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);
}
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);
}
}
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();
}
}
}
Aggregations