forked from j62/ctbrec
Fixed player start for recordings starting with a dash
This commit is contained in:
parent
8cdc2a4a56
commit
cd5172613e
|
@ -1,11 +1,13 @@
|
||||||
package ctbrec.ui;
|
package ctbrec.ui;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.security.InvalidKeyException;
|
import java.security.InvalidKeyException;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -17,7 +19,6 @@ import ctbrec.Hmac;
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
import ctbrec.OS;
|
import ctbrec.OS;
|
||||||
import ctbrec.Recording;
|
import ctbrec.Recording;
|
||||||
import ctbrec.io.DevNull;
|
|
||||||
import ctbrec.io.StreamRedirectThread;
|
import ctbrec.io.StreamRedirectThread;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
import ctbrec.ui.controls.Dialogs;
|
import ctbrec.ui.controls.Dialogs;
|
||||||
|
@ -127,7 +128,7 @@ public class Player {
|
||||||
try {
|
try {
|
||||||
if (cfg.getSettings().localRecording && rec != null) {
|
if (cfg.getSettings().localRecording && rec != null) {
|
||||||
File file = new File(cfg.getSettings().recordingsDir, rec.getPath());
|
File file = new File(cfg.getSettings().recordingsDir, rec.getPath());
|
||||||
String[] cmdline = createCmdline(file.getName());
|
String[] cmdline = createCmdline(file.getAbsolutePath());
|
||||||
playerProcess = rt.exec(cmdline, OS.getEnvironment(), file.getParentFile());
|
playerProcess = rt.exec(cmdline, OS.getEnvironment(), file.getParentFile());
|
||||||
} else {
|
} else {
|
||||||
if (rec != null) {
|
if (rec != null) {
|
||||||
|
@ -140,13 +141,13 @@ public class Player {
|
||||||
|
|
||||||
// create threads, which read stdout and stderr of the player process. these are needed,
|
// create threads, which read stdout and stderr of the player process. these are needed,
|
||||||
// because otherwise the internal buffer for these streams fill up and block the process
|
// because otherwise the internal buffer for these streams fill up and block the process
|
||||||
Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), new DevNull()));
|
Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), OutputStream.nullOutputStream()));
|
||||||
// Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), System.out));
|
//Thread std = new Thread(new StreamRedirectThread(playerProcess.getInputStream(), System.out));
|
||||||
std.setName("Player stdout pipe");
|
std.setName("Player stdout pipe");
|
||||||
std.setDaemon(true);
|
std.setDaemon(true);
|
||||||
std.start();
|
std.start();
|
||||||
Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), new DevNull()));
|
Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), OutputStream.nullOutputStream()));
|
||||||
// Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), System.err));
|
//Thread err = new Thread(new StreamRedirectThread(playerProcess.getErrorStream(), System.err));
|
||||||
err.setName("Player stderr pipe");
|
err.setName("Player stderr pipe");
|
||||||
err.setDaemon(true);
|
err.setDaemon(true);
|
||||||
err.start();
|
err.start();
|
||||||
|
@ -163,11 +164,12 @@ public class Player {
|
||||||
private String[] createCmdline(String mediaSource) {
|
private String[] createCmdline(String mediaSource) {
|
||||||
Config cfg = Config.getInstance();
|
Config cfg = Config.getInstance();
|
||||||
String[] playerArgs = cfg.getSettings().mediaPlayerParams.trim().split(" ");
|
String[] playerArgs = cfg.getSettings().mediaPlayerParams.trim().split(" ");
|
||||||
String[] cmdline = new String[playerArgs.length + 3];
|
String[] cmdline = new String[playerArgs.length + 2];
|
||||||
cmdline[0] = cfg.getSettings().mediaPlayer;
|
cmdline[0] = cfg.getSettings().mediaPlayer;
|
||||||
cmdline[cmdline.length - 2] = "--";
|
//cmdline[cmdline.length - 2] = "--";
|
||||||
cmdline[cmdline.length - 1] = mediaSource;
|
cmdline[cmdline.length - 1] = mediaSource;
|
||||||
System.arraycopy(playerArgs, 0, cmdline, 1, playerArgs.length);
|
System.arraycopy(playerArgs, 0, cmdline, 1, playerArgs.length);
|
||||||
|
LOG.debug("Player command line: {}", Arrays.toString(cmdline));
|
||||||
return cmdline;
|
return cmdline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
package ctbrec.io;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.OutputStream;
|
|
||||||
|
|
||||||
public class DevNull extends OutputStream {
|
|
||||||
@Override
|
|
||||||
public void write(int b) throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(byte[] b) throws IOException {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(byte[] b, int off, int len) throws IOException {
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue