use of com.frostwire.gui.player.MediaSource in project frostwire by frostwire.
the class GUIUtils method launchAndEnqueueFile.
/**
* Launches an audio file.
* If the FrostWire media player is enabled it will enqueue the song on the
* playlist. It won't take into consideration if the song is complete or not.
* If the frostwire player isn't enabled it will just use whatever is configured
* as an external player to launch the file.
*
* Note, this wont take in consideration if the song is being played or not.
* It will launch it no matter what (maybe this causes problems)
*
* @param file
* @param audioLaunched
* @return True if the song was launched with frostplayer
*/
public static boolean launchAndEnqueueFile(File file, boolean audioLaunched) {
if (MediaPlayer.isPlayableFile(file) && GUIMediator.isPlaylistVisible()) {
GUIMediator.instance().attemptStopAudio();
GUIMediator.instance().launchMedia(new MediaSource(file), false);
return true;
} else {
// use external player to launch file
return launchFile(file, false, audioLaunched);
}
// return false;
}
use of com.frostwire.gui.player.MediaSource in project frostwire by frostwire.
the class LibraryPlaylistsTableMediator method playMedia.
private void playMedia() {
LibraryPlaylistsTableDataLine line = DATA_MODEL.get(TABLE.getSelectedRow());
if (line == null || line.getPlayListItem() == null) {
return;
}
MediaSource mediaSource = new MediaSource(line.getPlayListItem());
if (MediaPlayer.isPlayableFile(mediaSource)) {
MediaPlayer.instance().asyncLoadMedia(mediaSource, true, currentPlaylist, getFilesView());
uxLogPlayFromPlaylists();
}
}
use of com.frostwire.gui.player.MediaSource in project frostwire by frostwire.
the class LibraryMediator method selectCurrentMedia.
public void selectCurrentMedia() {
// Select current playlist.
Playlist currentPlaylist = MediaPlayer.instance().getCurrentPlaylist();
final MediaSource currentMedia = MediaPlayer.instance().getCurrentMedia();
// If the current song is being played from a playlist.
if (currentPlaylist != null && currentMedia != null && currentMedia.getPlaylistItem() != null) {
if (currentPlaylist.getId() != LibraryDatabase.STARRED_PLAYLIST_ID) {
// select the song once it's available on the right hand side
getLibraryPlaylists().enqueueRunnable(new Runnable() {
public void run() {
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryPlaylistsTableMediator.instance().setItemSelected(currentMedia.getPlaylistItem());
}
});
}
});
// select the playlist
getLibraryPlaylists().selectPlaylist(currentPlaylist);
} else {
LibraryExplorer libraryFiles = getLibraryExplorer();
// select the song once it's available on the right hand side
libraryFiles.enqueueRunnable(new Runnable() {
public void run() {
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryPlaylistsTableMediator.instance().setItemSelected(currentMedia.getPlaylistItem());
}
});
}
});
libraryFiles.selectStarred();
}
} else if (currentMedia != null && currentMedia.getFile() != null) {
// selects the audio node at the top
LibraryExplorer libraryFiles = getLibraryExplorer();
// select the song once it's available on the right hand side
libraryFiles.enqueueRunnable(new Runnable() {
public void run() {
GUIMediator.safeInvokeLater(new Runnable() {
public void run() {
LibraryFilesTableMediator.instance().setFileSelected(currentMedia.getFile());
}
});
}
});
libraryFiles.selectAudio();
}
// Scroll to current song.
}
use of com.frostwire.gui.player.MediaSource in project frostwire by frostwire.
the class LibraryFilesTableMediator method getFilesView.
public List<MediaSource> getFilesView() {
int size = DATA_MODEL.getRowCount();
List<MediaSource> result = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
try {
File file = DATA_MODEL.get(i).getFile();
if (MediaPlayer.isPlayableFile(file)) {
result.add(new MediaSource(DATA_MODEL.get(i).getFile()));
}
} catch (Exception e) {
return Collections.emptyList();
}
}
return result;
}
Aggregations