/** Creates new form DataContentViewerVideo */ public DataContentViewerMedia() { initComponents(); // get the right panel for our platform videoPanel = MediaViewVideoPanel.createVideoPanel(); imagePanel = new MediaViewImagePanel(); videoPanelInited = videoPanel.isInited(); imagePanelInited = imagePanel.isInited(); videoExtensions = videoPanel.getExtensions(); customizeComponents(); logger.log(Level.INFO, "Created MediaView instance: " + this); }
@Override public boolean isSupported(Node node) { if (node == null) { return false; } AbstractFile file = node.getLookup().lookup(AbstractFile.class); if (file == null) { return false; } if (file.getSize() == 0) { return false; } String name = file.getName().toLowerCase(); if (imagePanelInited) { if (containsExt(name, imageExtensions)) { return true; } else if (Utilities.isJpegFileHeader(file)) { return true; } // for gstreamer formats, check if initialized first, then // support audio formats, and video formats } if (videoPanelInited && videoPanel.isInited()) { if (containsExt(name, AUDIO_EXTENSIONS) || (containsExt(name, videoExtensions))) { return true; } } return false; }
@Override public void setNode(Node selectedNode) { try { if (selectedNode == null) { resetComponent(); return; } AbstractFile file = selectedNode.getLookup().lookup(AbstractFile.class); if (file == null) { resetComponent(); return; } if (file.equals(lastFile)) { return; // prevent from loading twice if setNode() called mult. times } lastFile = file; final Dimension dims = DataContentViewerMedia.this.getSize(); logger.info("setting node on media viewer"); if (imagePanelInited && containsExt(file.getName(), imageExtensions)) { imagePanel.showImageFx(file, dims); this.switchPanels(false); } else if (imagePanelInited && Utilities.isJpegFileHeader(file)) { imagePanel.showImageFx(file, dims); this.switchPanels(false); } else if (videoPanelInited && (containsExt(file.getName(), videoExtensions) || containsExt(file.getName(), AUDIO_EXTENSIONS))) { videoPanel.setupVideo(file, dims); switchPanels(true); } } catch (Exception e) { logger.log(Level.SEVERE, "Exception while setting node", e); } }
@Override public void resetComponent() { videoPanel.reset(); lastFile = null; }