use of com.limegroup.gnutella.gui.util.GUILauncher.LaunchableProvider in project frostwire by frostwire.
the class LibraryFilesTableMediator method launch.
/**
* Launches the associated applications for each selected file
* in the library if it can.
*/
private void launch(boolean playAudio) {
int[] rows = TABLE.getSelectedRows();
if (rows.length == 0) {
return;
}
File selectedFile = DATA_MODEL.getFile(rows[0]);
if (OSUtils.isWindows()) {
if (selectedFile.isDirectory()) {
GUIMediator.launchExplorer(selectedFile);
return;
} else if (!MediaPlayer.isPlayableFile(selectedFile)) {
String extension = FilenameUtils.getExtension(selectedFile.getName());
if (extension != null && extension.toLowerCase().equals("torrent")) {
GUIMediator.instance().openTorrentFile(selectedFile, true);
} else {
GUIMediator.launchFile(selectedFile);
}
return;
}
}
LaunchableProvider[] providers = new LaunchableProvider[rows.length];
boolean stopAudio = false;
for (int i = 0; i < rows.length; i++) {
try {
MediaType mt = MediaType.getMediaTypeForExtension(FilenameUtils.getExtension(DATA_MODEL.getFile(rows[i]).getName()));
if (mt != null && mt.equals(MediaType.getVideoMediaType())) {
stopAudio = true;
}
} catch (Throwable e) {
// ignore
}
providers[i] = new FileProvider(DATA_MODEL.getFile(rows[i]));
}
if (stopAudio || !playAudio) {
MediaPlayer.instance().stop();
}
if (playAudio) {
GUILauncher.launch(providers);
UXStats.instance().log(stopAudio ? UXAction.LIBRARY_VIDEO_PLAY : UXAction.LIBRARY_PLAY_AUDIO_FROM_FILE);
} else {
GUIMediator.launchFile(selectedFile);
}
}
use of com.limegroup.gnutella.gui.util.GUILauncher.LaunchableProvider in project frostwire by frostwire.
the class LibraryPlaylistsTableMediator method launch.
/**
* Launches the associated applications for each selected file
* in the library if it can.
*/
private void launch(boolean playMedia) {
int[] rows = TABLE.getSelectedRows();
if (rows.length == 0) {
return;
}
File selectedFile = DATA_MODEL.getFile(rows[0]);
if (OSUtils.isWindows()) {
if (selectedFile.isDirectory()) {
GUIMediator.launchExplorer(selectedFile);
return;
} else if (!MediaPlayer.isPlayableFile(selectedFile)) {
GUIMediator.launchFile(selectedFile);
return;
}
}
LaunchableProvider[] providers = new LaunchableProvider[rows.length];
for (int i = 0; i < rows.length; i++) {
providers[i] = new FileProvider(DATA_MODEL.getFile(rows[i]));
}
if (!playMedia) {
MediaPlayer.instance().stop();
}
if (playMedia) {
GUILauncher.launch(providers);
uxLogPlayFromPlaylists();
} else {
GUIMediator.launchFile(selectedFile);
}
}
Aggregations