diff --git a/client/src/main/java/ctbrec/ui/CamrecApplication.java b/client/src/main/java/ctbrec/ui/CamrecApplication.java index f83ed92d..7dd22304 100644 --- a/client/src/main/java/ctbrec/ui/CamrecApplication.java +++ b/client/src/main/java/ctbrec/ui/CamrecApplication.java @@ -276,7 +276,7 @@ public class CamrecApplication extends Application { .addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowHeight = newVal.intValue()); primaryStage.setMaximized(Config.getInstance().getSettings().windowMaximized); 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.setY(Config.getInstance().getSettings().windowY); primaryStage.xProperty().addListener((observable, oldVal, newVal) -> { diff --git a/client/src/main/java/ctbrec/ui/Player.java b/client/src/main/java/ctbrec/ui/Player.java index c8bcd0e8..a1d9bd64 100644 --- a/client/src/main/java/ctbrec/ui/Player.java +++ b/client/src/main/java/ctbrec/ui/Player.java @@ -1,5 +1,21 @@ 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.IOException; import java.io.OutputStream; @@ -13,32 +29,10 @@ import java.util.Iterator; import java.util.List; 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 { private static final Logger LOG = LoggerFactory.getLogger(Player.class); private static PlayerThread playerThread; - public static Scene scene; + private static Scene scene; private Player() { } @@ -187,7 +181,7 @@ public class Player { } } 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 { LOG.debug("{} selected {}", model.getName(), sources.get(sources.size() - 1)); best = sources.get(sources.size() - 1); @@ -208,7 +202,7 @@ public class Player { Config cfg = Config.getInstance(); String params = cfg.getSettings().mediaPlayerParams.trim(); - String[] cmdline = null; + String[] cmdline; if (params.isEmpty()) { cmdline = new String[2]; } else { @@ -241,4 +235,8 @@ public class Player { } } } + + public static void setScene(Scene scene) { + Player.scene = scene; + } } diff --git a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java index b182b1da..fd5b7ad3 100644 --- a/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/dash/DashDownload.java @@ -27,6 +27,7 @@ import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; +import ctbrec.recorder.download.hls.NoStreamFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -299,7 +300,7 @@ public class DashDownload extends AbstractDownload { AdaptationSetType video = chooseBestVideo(videoStreams); if (video == null) { - throw new ExecutionException(new RuntimeException("No stream left in playlist")); + throw new ExecutionException(new NoStreamFoundException("No stream left in playlist")); } else { int downloaded = downloadSegments(mpd, video, true); diff --git a/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java b/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java index fff1eac6..eb5a3011 100644 --- a/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/hls/AbstractHlsDownload.java @@ -248,7 +248,7 @@ public abstract class AbstractHlsDownload extends AbstractDownload { .collect(Collectors.toList()); if (filteredStreamSources.isEmpty()) { - throw new ExecutionException(new RuntimeException("No stream left in playlist")); + throw new ExecutionException(new NoStreamFoundException("No stream left in playlist")); } else { StreamSource source = filteredStreamSources.get(filteredStreamSources.size() - 1); LOG.debug("{} selected {}", model.getName(), source); diff --git a/common/src/main/java/ctbrec/recorder/download/hls/HlsdlDownload.java b/common/src/main/java/ctbrec/recorder/download/hls/HlsdlDownload.java index 6b555192..173e891d 100644 --- a/common/src/main/java/ctbrec/recorder/download/hls/HlsdlDownload.java +++ b/common/src/main/java/ctbrec/recorder/download/hls/HlsdlDownload.java @@ -150,7 +150,7 @@ public class HlsdlDownload extends AbstractDownload { .collect(Collectors.toList()); if (filteredStreamSources.isEmpty()) { - throw new ExecutionException(new RuntimeException("No stream left in playlist")); + throw new ExecutionException(new NoStreamFoundException("No stream left in playlist")); } else { LOG.debug("{} selected {}", model.getName(), filteredStreamSources.get(filteredStreamSources.size() - 1)); url = filteredStreamSources.get(filteredStreamSources.size() - 1).getMediaPlaylistUrl(); diff --git a/common/src/main/java/ctbrec/recorder/download/hls/NoStreamFoundException.java b/common/src/main/java/ctbrec/recorder/download/hls/NoStreamFoundException.java new file mode 100644 index 00000000..b7e05c74 --- /dev/null +++ b/common/src/main/java/ctbrec/recorder/download/hls/NoStreamFoundException.java @@ -0,0 +1,7 @@ +package ctbrec.recorder.download.hls; + +public class NoStreamFoundException extends RuntimeException { + public NoStreamFoundException(String msg) { + super(msg); + } +}