mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
minor gstreamer tweaks
This commit is contained in:
parent
373b256058
commit
8f80324fa3
@ -58,7 +58,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
private File currentFile;
|
||||
private long durationMillis = 0;
|
||||
private boolean autoTracking = false; // true if the slider is moving automatically
|
||||
private final Object playbinLock = new Object(); // lock for synchronization
|
||||
private final Object playbinLock = new Object(); // lock for synchronization of playbin2 player
|
||||
|
||||
/**
|
||||
* Creates new form DataContentViewerVideo
|
||||
@ -71,11 +71,10 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
private void customizeComponents() {
|
||||
Gst.init();
|
||||
progressSlider.addChangeListener(new ChangeListener() {
|
||||
|
||||
/**
|
||||
* Should always try to synchronize any call to
|
||||
* progressSlider.setValue() to avoid a different thread
|
||||
* changing playbin while stateChanged() is processing
|
||||
* progressSlider.setValue() to avoid a different thread changing
|
||||
* playbin while stateChanged() is processing
|
||||
*/
|
||||
@Override
|
||||
public void stateChanged(ChangeEvent e) {
|
||||
@ -89,7 +88,6 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@ -159,21 +157,21 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
|
||||
private void pauseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pauseButtonActionPerformed
|
||||
synchronized (playbinLock) {
|
||||
if(playbin2.getState().equals(State.PLAYING)){
|
||||
State state = playbin2.getState();
|
||||
if (state.equals(State.PLAYING)) {
|
||||
playbin2.pause();
|
||||
pauseButton.setText("►");
|
||||
playbin2.setState(State.PAUSED);
|
||||
} else if(playbin2.getState().equals(State.PAUSED)) {
|
||||
} else if (state.equals(State.PAUSED)) {
|
||||
playbin2.play();
|
||||
pauseButton.setText("||");
|
||||
playbin2.setState(State.PLAYING);
|
||||
} else if(playbin2.getState().equals(State.READY)) {
|
||||
} else if (state.equals(State.READY)) {
|
||||
ExtractMedia em = new ExtractMedia(currentFile, getJFile(currentFile));
|
||||
em.execute();
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_pauseButtonActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton pauseButton;
|
||||
private javax.swing.JLabel progressLabel;
|
||||
@ -185,10 +183,14 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
public void setNode(Node selectedNode) {
|
||||
reset();
|
||||
setComponentsVisibility(false);
|
||||
if(selectedNode == null) { return; }
|
||||
if (selectedNode == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
File file = selectedNode.getLookup().lookup(File.class);
|
||||
if(file == null) { return; }
|
||||
if (file == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
currentFile = file;
|
||||
if (containsExt(file.getName(), IMAGES)) {
|
||||
@ -200,6 +202,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
|
||||
/**
|
||||
* Initialize vars and display the image on the panel.
|
||||
*
|
||||
* @param file
|
||||
*/
|
||||
private void showImage(File file) {
|
||||
@ -233,6 +236,7 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
|
||||
/**
|
||||
* Initialize all the necessary vars to play a video/audio file.
|
||||
*
|
||||
* @param file the File to play
|
||||
*/
|
||||
private void setupVideo(File file) {
|
||||
@ -391,7 +395,9 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
ExtractMedia(org.sleuthkit.datamodel.File sFile, java.io.File jFile) {
|
||||
this.sFile = sFile;
|
||||
this.jFile = jFile;
|
||||
};
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
@Override
|
||||
protected Object doInBackground() throws Exception {
|
||||
@ -438,13 +444,16 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
progressLabel.setText("Error buffering file");
|
||||
return;
|
||||
}
|
||||
ClockTime dur = null;
|
||||
synchronized (playbinLock) {
|
||||
playbin2.play(); // must play, then pause and get state to get duration.
|
||||
playbin2.pause();
|
||||
playbin2.getState();
|
||||
duration = playbin2.queryDuration().toString();
|
||||
durationMillis = playbin2.queryDuration().toMillis();
|
||||
dur = playbin2.queryDuration();
|
||||
}
|
||||
duration = dur.toString();
|
||||
durationMillis = dur.toMillis();
|
||||
|
||||
progressSlider.setMaximum((int) durationMillis);
|
||||
progressSlider.setMinimum(0);
|
||||
final String finalDuration;
|
||||
@ -460,17 +469,24 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
}
|
||||
pauseButton.setText("||");
|
||||
new Thread(new Runnable() {
|
||||
private boolean isPlayBinReady() {
|
||||
synchronized (playbinLock) {
|
||||
return playbin2 != null && playbin2.getState().equals(State.NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
long positionMillis = 0;
|
||||
while (positionMillis < durationMillis
|
||||
&& playbin2 != null
|
||||
&& !playbin2.getState().equals(State.NULL)) {
|
||||
&& isPlayBinReady() ) {
|
||||
ClockTime pos = null;
|
||||
synchronized (playbinLock) {
|
||||
position = playbin2.queryPosition().toString();
|
||||
positionMillis = playbin2.queryPosition().toMillis();
|
||||
pos = playbin2.queryPosition();
|
||||
}
|
||||
position = pos.toString();
|
||||
positionMillis = pos.toMillis();
|
||||
|
||||
if (position.length() == 8) {
|
||||
position = position.substring(3);
|
||||
}
|
||||
@ -480,7 +496,8 @@ public class DataContentViewerMedia extends javax.swing.JPanel implements DataCo
|
||||
autoTracking = false;
|
||||
try {
|
||||
Thread.sleep(20);
|
||||
} catch (InterruptedException ex) { }
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
if (finalDuration.length() == 5) {
|
||||
progressLabel.setText("00:00/" + finalDuration);
|
||||
|
Loading…
x
Reference in New Issue
Block a user