19package org.sleuthkit.autopsy.contentviewers;
21import java.awt.CardLayout;
22import java.awt.Component;
23import java.util.ArrayList;
25import java.util.logging.Level;
26import org.freedesktop.gstreamer.GstException;
27import org.openide.util.NbBundle;
28import org.sleuthkit.autopsy.coreutils.Logger;
29import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
30import org.sleuthkit.datamodel.AbstractFile;
35@SuppressWarnings(
"PMD.SingularField")
36class MediaFileViewer extends javax.swing.JPanel implements
FileTypeViewer {
39 private static final long serialVersionUID = 1L;
40 private AbstractFile lastFile;
43 private final MediaViewImagePanel imagePanel;
44 private final boolean imagePanelInited;
46 private static final String IMAGE_VIEWER_LAYER =
"IMAGE";
47 private static final String MEDIA_PLAYER_LAYER =
"AUDIO_VIDEO";
58 }
catch (GstException | UnsatisfiedLinkError ex) {
59 LOGGER.log(Level.SEVERE,
"Error initializing gstreamer for audio/video viewing and frame extraction capabilities", ex);
61 NbBundle.getMessage(
this.getClass(),
"MediaFileViewer.initGst.gstException.msg"),
64 imagePanel =
new MediaViewImagePanel();
65 imagePanelInited = imagePanel.isInited();
67 customizeComponents();
68 LOGGER.log(Level.INFO,
"Created MediaView instance: {0}",
this);
71 private void customizeComponents() {
72 add(imagePanel, IMAGE_VIEWER_LAYER);
74 if (mediaPlayerPanel !=
null) {
75 add(mediaPlayerPanel, MEDIA_PLAYER_LAYER);
86 @SuppressWarnings(
"unchecked")
88 private
void initComponents() {
90 setLayout(
new java.awt.CardLayout());
91 getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(MediaFileViewer.class,
"MediaFileViewer.AccessibleContext.accessibleDescription"));
102 public List<String> getSupportedMIMETypes() {
104 List<String> mimeTypes =
new ArrayList<>();
106 mimeTypes.addAll(this.imagePanel.getSupportedMimeTypes());
107 if (mediaPlayerPanel !=
null) {
108 mimeTypes.addAll(this.mediaPlayerPanel.getSupportedMimeTypes());
120 public void setFile(AbstractFile file) {
128 if (file.equals(lastFile)) {
133 if (mediaPlayerPanel !=
null && mediaPlayerPanel.isSupported(file)) {
134 mediaPlayerPanel.loadFile(file);
135 this.showVideoPanel();
136 }
else if (imagePanelInited && imagePanel.isSupported(file)) {
137 imagePanel.loadFile(file);
138 this.showImagePanel();
140 }
catch (Exception e) {
141 LOGGER.log(Level.SEVERE,
"Exception while setting node", e);
148 private void showVideoPanel() {
149 CardLayout
layout = (CardLayout) this.getLayout();
150 layout.show(
this, MEDIA_PLAYER_LAYER);
156 private void showImagePanel() {
157 CardLayout
layout = (CardLayout) this.getLayout();
158 layout.show(
this, IMAGE_VIEWER_LAYER);
162 public Component getComponent() {
167 public void resetComponent() {
168 if (mediaPlayerPanel !=
null) {
169 mediaPlayerPanel.reset();
196 public boolean isSupported(AbstractFile file){
197 return mediaPlayerPanel.isSupported(file) || imagePanel.isSupported(file);
synchronized static Logger getLogger(String name)
static void error(String title, String message)
List< String > getSupportedExtensions()
boolean isSupported(AbstractFile file)
List< String > getSupportedMimeTypes()