This repository has been archived on 2018-03-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
jLSLauncher/src/com/ixab/StreamHandling/StreamOpener.java
T

42 lines
1.2 KiB
Java
Raw Normal View History

2015-11-06 18:15:26 +01:00
package com.ixab.StreamHandling;
import com.ixab.ConfigHandling.Config;
2015-11-09 20:09:55 +01:00
import com.ixab.GUI.MainWindow;
import com.ixab.Logging.Logger;
2015-11-06 18:15:26 +01:00
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class StreamOpener extends Thread {
private Config c;
2015-11-09 20:09:55 +01:00
private String streamName;
2015-11-06 18:15:26 +01:00
private String quality;
public StreamOpener(Config c, int streamIndex, String quality) {
this.c = c;
2015-11-09 20:09:55 +01:00
this.streamName = c.getStreamName(streamIndex);
2015-11-06 18:15:26 +01:00
this.quality = quality;
}
public void run() {
try {
Runtime rt = Runtime.getRuntime();
2015-11-09 20:09:55 +01:00
Process pr = rt.exec(this.c.getLSPath()+" twitch.tv/"+this.streamName+" "+this.quality);
2015-11-06 18:15:26 +01:00
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line=null;
while((line=input.readLine()) != null) {
Logger.print(line, this);
2015-11-09 20:09:55 +01:00
// TODO: analyze livestreamer output and inform gui on errors
2015-11-06 18:15:26 +01:00
}
int exitVal = pr.waitFor();
Logger.print("Exited with error code " + exitVal, this);
2015-11-06 18:15:26 +01:00
} catch(Exception e) {
Logger.print(e.toString(), this);
2015-11-06 18:15:26 +01:00
e.printStackTrace();
}
}
}