use of com.limegroup.gnutella.MediaType 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.MediaType in project frostwire by frostwire.
the class NativeFileIconController method preload.
/**
* Preloads a bunch of icons.
*/
private void preload() {
ExecutorService queue = ExecutorsHelper.newProcessingQueue("IconLoader");
final MediaType[] types = MediaType.getDefaultMediaTypes();
final AtomicBoolean continueLoading = new AtomicBoolean(true);
for (int i = 0; i < types.length && continueLoading.get(); i++) {
final Set<?> exts = types[i].getExtensions();
for (Iterator<?> j = exts.iterator(); j.hasNext() && continueLoading.get(); ) {
final String next = (String) j.next();
queue.execute(new Runnable() {
public void run() {
GUIMediator.safeInvokeAndWait(new Runnable() {
public void run() {
getIconForExtension(next);
if (!VIEW.isViewAvailable())
continueLoading.set(false);
}
});
}
});
}
}
}
use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class SearchResultActionsRenderer method isSearchResultPlayable.
private boolean isSearchResultPlayable() {
boolean playable = false;
if (searchResult.getSearchResult() instanceof StreamableSearchResult) {
playable = ((StreamableSearchResult) searchResult.getSearchResult()).getStreamUrl() != null;
}
if (playable && searchResult.getExtension() != null) {
MediaType mediaType = MediaType.getMediaTypeForExtension(searchResult.getExtension());
playable = mediaType != null && (mediaType.equals(MediaType.getAudioMediaType())) || mediaType.equals(MediaType.getVideoMediaType());
}
return playable;
}
use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class SearchResultActionsRenderer method uxLogMediaPreview.
private void uxLogMediaPreview() {
MediaType mediaType = MediaType.getMediaTypeForExtension(searchResult.getExtension());
if (mediaType != null) {
boolean isVideo = mediaType.equals(MediaType.getVideoMediaType());
UXStats.instance().log(isVideo ? UXAction.SEARCH_RESULT_VIDEO_PREVIEW : UXAction.SEARCH_RESULT_AUDIO_PREVIEW);
}
}
use of com.limegroup.gnutella.MediaType in project frostwire by frostwire.
the class AbstractUISearchResult method play.
@Override
public void play() {
// this gets invoked when clicking on a search result play preview button.
if (sr instanceof StreamableSearchResult) {
StreamableSearchResult ssr = (StreamableSearchResult) sr;
String streamUrl = ssr.getStreamUrl();
MediaType mediaType = MediaType.getMediaTypeForExtension(extension);
if (mediaType != null) {
boolean isVideo = mediaType.equals(MediaType.getVideoMediaType());
if (isVideo) {
boolean videoPreviewInBrowser = !PlayerSettings.USE_FW_PLAYER_FOR_CLOUD_VIDEO_PREVIEWS.getValue() && sr instanceof YouTubeCrawledStreamableSearchResult;
if (videoPreviewInBrowser) {
GUIMediator.instance().launchYouTubePreviewInBrowser(((YouTubeCrawledStreamableSearchResult) sr));
} else {
GUIMediator.instance().launchMedia(new StreamMediaSource(streamUrl, sr.getDisplayName(), sr.getDetailsUrl(), true), true);
}
} else {
GUIMediator.instance().launchMedia(new StreamMediaSource(streamUrl, sr.getDisplayName(), sr.getDetailsUrl(), false), true);
}
}
}
}
Aggregations