/** Launches the associated applications for each selected file in the library if it can. */ 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); } else { GUIMediator.launchFile(selectedFile); } }
public void actionPerformed(ActionEvent ae) { int[] sel = TABLE.getSelectedRows(); if (sel.length == 0) { return; } File selectedFile = getFile(sel[0]); if (selectedFile.isFile() && selectedFile.getParentFile() != null) { GUIMediator.launchExplorer(selectedFile); } }
/** Launches the associated applications for each selected file in the library if it can. */ 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.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.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); } }
public void performAction(ActionEvent e) { BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders(); if (downloaders.length > 0) { // when the downloader is a single file, this is appending a folder to the actual file path // treating it like a bittorrent download. File toExplore = new File(downloaders[0].getSaveLocation(), downloaders[0].getDisplayName()); if (toExplore != null) { // but perhaps it's a single file, make sure it is then... (Re: Issue #366) if (!toExplore.exists() && downloaders[0].getSaveLocation() != null && downloaders[0].getSaveLocation().isFile()) { // (made this if very explicit and dumb on purpose to make logic clear, reverse logic is // shorter) toExplore = downloaders[0].getSaveLocation(); } if (toExplore.exists()) { GUIMediator.launchExplorer(toExplore); } } } }