forked from j62/ctbrec
Code cleanup
This commit is contained in:
parent
0772b8e057
commit
14f9cce1ae
|
@ -276,7 +276,7 @@ public class CamrecApplication extends Application {
|
||||||
.addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowHeight = newVal.intValue());
|
.addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowHeight = newVal.intValue());
|
||||||
primaryStage.setMaximized(Config.getInstance().getSettings().windowMaximized);
|
primaryStage.setMaximized(Config.getInstance().getSettings().windowMaximized);
|
||||||
primaryStage.maximizedProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowMaximized = newVal);
|
primaryStage.maximizedProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowMaximized = newVal);
|
||||||
Player.scene = primaryStage.getScene();
|
Player.setScene(primaryStage.getScene());
|
||||||
primaryStage.setX(Config.getInstance().getSettings().windowX);
|
primaryStage.setX(Config.getInstance().getSettings().windowX);
|
||||||
primaryStage.setY(Config.getInstance().getSettings().windowY);
|
primaryStage.setY(Config.getInstance().getSettings().windowY);
|
||||||
primaryStage.xProperty().addListener((observable, oldVal, newVal) -> {
|
primaryStage.xProperty().addListener((observable, oldVal, newVal) -> {
|
||||||
|
|
|
@ -1,5 +1,21 @@
|
||||||
package ctbrec.ui;
|
package ctbrec.ui;
|
||||||
|
|
||||||
|
import com.iheartradio.m3u8.ParseException;
|
||||||
|
import com.iheartradio.m3u8.PlaylistException;
|
||||||
|
import ctbrec.*;
|
||||||
|
import ctbrec.event.EventBusHolder;
|
||||||
|
import ctbrec.io.StreamRedirector;
|
||||||
|
import ctbrec.io.UrlUtil;
|
||||||
|
import ctbrec.recorder.download.StreamSource;
|
||||||
|
import ctbrec.recorder.download.hls.NoStreamFoundException;
|
||||||
|
import ctbrec.ui.controls.Dialogs;
|
||||||
|
import ctbrec.ui.event.PlayerStartedEvent;
|
||||||
|
import ctbrec.variableexpansion.ModelVariableExpander;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import javax.xml.bind.JAXBException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -13,32 +29,10 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import com.iheartradio.m3u8.ParseException;
|
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
|
||||||
|
|
||||||
import ctbrec.Config;
|
|
||||||
import ctbrec.Model;
|
|
||||||
import ctbrec.OS;
|
|
||||||
import ctbrec.Recording;
|
|
||||||
import ctbrec.StringUtil;
|
|
||||||
import ctbrec.event.EventBusHolder;
|
|
||||||
import ctbrec.io.StreamRedirector;
|
|
||||||
import ctbrec.io.UrlUtil;
|
|
||||||
import ctbrec.recorder.download.StreamSource;
|
|
||||||
import ctbrec.ui.controls.Dialogs;
|
|
||||||
import ctbrec.ui.event.PlayerStartedEvent;
|
|
||||||
import ctbrec.variableexpansion.ModelVariableExpander;
|
|
||||||
import javafx.scene.Scene;
|
|
||||||
|
|
||||||
public class Player {
|
public class Player {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(Player.class);
|
private static final Logger LOG = LoggerFactory.getLogger(Player.class);
|
||||||
private static PlayerThread playerThread;
|
private static PlayerThread playerThread;
|
||||||
public static Scene scene;
|
private static Scene scene;
|
||||||
|
|
||||||
private Player() {
|
private Player() {
|
||||||
}
|
}
|
||||||
|
@ -187,7 +181,7 @@ public class Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sources.isEmpty()) {
|
if (sources.isEmpty()) {
|
||||||
throw new RuntimeException("No stream left in playlist, because player resolution is set to " + maxRes);
|
throw new NoStreamFoundException("No stream left in playlist, because player resolution is set to " + maxRes);
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("{} selected {}", model.getName(), sources.get(sources.size() - 1));
|
LOG.debug("{} selected {}", model.getName(), sources.get(sources.size() - 1));
|
||||||
best = sources.get(sources.size() - 1);
|
best = sources.get(sources.size() - 1);
|
||||||
|
@ -208,7 +202,7 @@ public class Player {
|
||||||
Config cfg = Config.getInstance();
|
Config cfg = Config.getInstance();
|
||||||
String params = cfg.getSettings().mediaPlayerParams.trim();
|
String params = cfg.getSettings().mediaPlayerParams.trim();
|
||||||
|
|
||||||
String[] cmdline = null;
|
String[] cmdline;
|
||||||
if (params.isEmpty()) {
|
if (params.isEmpty()) {
|
||||||
cmdline = new String[2];
|
cmdline = new String[2];
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,4 +235,8 @@ public class Player {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setScene(Scene scene) {
|
||||||
|
Player.scene = scene;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ import javax.xml.bind.JAXBElement;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import javax.xml.bind.Unmarshaller;
|
import javax.xml.bind.Unmarshaller;
|
||||||
|
|
||||||
|
import ctbrec.recorder.download.hls.NoStreamFoundException;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -299,7 +300,7 @@ public class DashDownload extends AbstractDownload {
|
||||||
|
|
||||||
AdaptationSetType video = chooseBestVideo(videoStreams);
|
AdaptationSetType video = chooseBestVideo(videoStreams);
|
||||||
if (video == null) {
|
if (video == null) {
|
||||||
throw new ExecutionException(new RuntimeException("No stream left in playlist"));
|
throw new ExecutionException(new NoStreamFoundException("No stream left in playlist"));
|
||||||
} else {
|
} else {
|
||||||
int downloaded = downloadSegments(mpd, video, true);
|
int downloaded = downloadSegments(mpd, video, true);
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (filteredStreamSources.isEmpty()) {
|
if (filteredStreamSources.isEmpty()) {
|
||||||
throw new ExecutionException(new RuntimeException("No stream left in playlist"));
|
throw new ExecutionException(new NoStreamFoundException("No stream left in playlist"));
|
||||||
} else {
|
} else {
|
||||||
StreamSource source = filteredStreamSources.get(filteredStreamSources.size() - 1);
|
StreamSource source = filteredStreamSources.get(filteredStreamSources.size() - 1);
|
||||||
LOG.debug("{} selected {}", model.getName(), source);
|
LOG.debug("{} selected {}", model.getName(), source);
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class HlsdlDownload extends AbstractDownload {
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
if (filteredStreamSources.isEmpty()) {
|
if (filteredStreamSources.isEmpty()) {
|
||||||
throw new ExecutionException(new RuntimeException("No stream left in playlist"));
|
throw new ExecutionException(new NoStreamFoundException("No stream left in playlist"));
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("{} selected {}", model.getName(), filteredStreamSources.get(filteredStreamSources.size() - 1));
|
LOG.debug("{} selected {}", model.getName(), filteredStreamSources.get(filteredStreamSources.size() - 1));
|
||||||
url = filteredStreamSources.get(filteredStreamSources.size() - 1).getMediaPlaylistUrl();
|
url = filteredStreamSources.get(filteredStreamSources.size() - 1).getMediaPlaylistUrl();
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
package ctbrec.recorder.download.hls;
|
||||||
|
|
||||||
|
public class NoStreamFoundException extends RuntimeException {
|
||||||
|
public NoStreamFoundException(String msg) {
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue