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;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -17,7 +19,6 @@ import ctbrec.Hmac;
|
|||
import ctbrec.Model;
|
||||
import ctbrec.OS;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.io.DevNull;
|
||||
import ctbrec.io.StreamRedirectThread;
|
||||
import ctbrec.recorder.download.StreamSource;
|
||||
import ctbrec.ui.controls.Dialogs;
|
||||
|
@ -127,7 +128,7 @@ public class Player {
|
|||
try {
|
||||
if (cfg.getSettings().localRecording && rec != null) {
|
||||
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());
|
||||
} else {
|
||||
if (rec != null) {
|
||||
|
@ -140,12 +141,12 @@ public class Player {
|
|||
|
||||
// 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
|
||||
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));
|
||||
std.setName("Player stdout pipe");
|
||||
std.setDaemon(true);
|
||||
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));
|
||||
err.setName("Player stderr pipe");
|
||||
err.setDaemon(true);
|
||||
|
@ -163,11 +164,12 @@ public class Player {
|
|||
private String[] createCmdline(String mediaSource) {
|
||||
Config cfg = Config.getInstance();
|
||||
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[cmdline.length - 2] = "--";
|
||||
//cmdline[cmdline.length - 2] = "--";
|
||||
cmdline[cmdline.length - 1] = mediaSource;
|
||||
System.arraycopy(playerArgs, 0, cmdline, 1, playerArgs.length);
|
||||
LOG.debug("Player command line: {}", Arrays.toString(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