19 package org.sleuthkit.autopsy.contentviewers;
21 import java.awt.CardLayout;
22 import java.awt.Component;
23 import java.awt.Dimension;
24 import java.util.ArrayList;
25 import java.util.List;
26 import java.util.logging.Level;
33 @SuppressWarnings(
"PMD.SingularField")
34 class MediaFileViewer extends javax.swing.JPanel implements FileTypeViewer {
36 private static final Logger LOGGER = Logger.getLogger(MediaFileViewer.class.getName());
37 private AbstractFile lastFile;
39 private final MediaViewVideoPanel videoPanel;
40 private final boolean videoPanelInited;
41 private final MediaViewImagePanel imagePanel;
42 private final boolean imagePanelInited;
44 private static final String IMAGE_VIEWER_LAYER =
"IMAGE";
45 private static final String VIDEO_VIEWER_LAYER =
"VIDEO";
50 public MediaFileViewer() {
55 videoPanel = MediaViewVideoPanel.createVideoPanel();
56 videoPanelInited = videoPanel.isInited();
58 imagePanel =
new MediaViewImagePanel();
59 imagePanelInited = imagePanel.isInited();
61 customizeComponents();
62 LOGGER.log(Level.INFO,
"Created MediaView instance: {0}",
this);
65 private void customizeComponents() {
66 add(imagePanel, IMAGE_VIEWER_LAYER);
67 add(videoPanel, VIDEO_VIEWER_LAYER);
69 showVideoPanel(
false);
77 @SuppressWarnings(
"unchecked")
79 private
void initComponents() {
81 setLayout(
new java.awt.CardLayout());
82 getAccessibleContext().setAccessibleDescription(
org.openide.util.NbBundle.getMessage(MediaFileViewer.class,
"MediaFileViewer.AccessibleContext.accessibleDescription"));
93 public List<String> getSupportedMIMETypes() {
95 List<String> mimeTypes =
new ArrayList<>();
97 mimeTypes.addAll(this.imagePanel.getMimeTypes());
98 mimeTypes.addAll(this.videoPanel.getMimeTypes());
110 public void setFile(AbstractFile file) {
118 if (file.equals(lastFile)) {
124 final Dimension dims = MediaFileViewer.this.getSize();
126 if (videoPanelInited && videoPanel.isSupported(file)) {
127 videoPanel.setupVideo(file, dims);
128 this.showVideoPanel(
true);
129 }
else if (imagePanelInited && imagePanel.isSupported(file)) {
130 imagePanel.showImageFx(file, dims);
131 this.showVideoPanel(
false);
133 }
catch (Exception e) {
134 LOGGER.log(Level.SEVERE,
"Exception while setting node", e);
143 private void showVideoPanel(
boolean showVideo) {
144 CardLayout layout = (CardLayout) this.getLayout();
146 layout.show(
this, VIDEO_VIEWER_LAYER);
148 layout.show(
this, IMAGE_VIEWER_LAYER);
153 public Component getComponent() {
158 public void resetComponent() {
164 interface MediaViewPanel {
169 List<String> getMimeTypes();
176 List<String> getExtensionsList();
178 boolean isSupported(AbstractFile file);