Add error handler for the video player

This commit is contained in:
0xboobface 2018-12-01 14:01:50 +01:00
parent 53f77afb85
commit f1eaa75a57
1 changed files with 12 additions and 0 deletions

View File

@ -185,6 +185,7 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
Collections.sort(sources); Collections.sort(sources);
StreamSource best = sources.get(0); StreamSource best = sources.get(0);
checkInterrupt(); checkInterrupt();
LOG.debug("Preview url for {} is {}", model.getName(), best.getMediaPlaylistUrl());
video = new Media(best.getMediaPlaylistUrl()); video = new Media(best.getMediaPlaylistUrl());
if(videoPlayer != null) { if(videoPlayer != null) {
videoPlayer.dispose(); videoPlayer.dispose();
@ -206,6 +207,7 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
}); });
} }
}); });
videoPlayer.setOnError(() -> onError(videoPlayer));
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
if(e.getMessage().equals("Stream url unknown")) { if(e.getMessage().equals("Stream url unknown")) {
// fine hls url for mfc not known yet // fine hls url for mfc not known yet
@ -229,6 +231,16 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
}); });
} }
private void onError(MediaPlayer videoPlayer) {
LOG.error("Error while starting preview stream", videoPlayer.getError());
if(videoPlayer.getError().getCause() != null) {
LOG.error("Error while starting preview stream root cause:", videoPlayer.getError().getCause());
}
Platform.runLater(() -> {
showTestImage();
});
}
private void resize(double w, double h) { private void resize(double w, double h) {
preview.setFitWidth(w); preview.setFitWidth(w);
preview.setFitHeight(h); preview.setFitHeight(h);