Add error handler for the video player
This commit is contained in:
parent
53f77afb85
commit
f1eaa75a57
|
@ -185,6 +185,7 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
|
|||
Collections.sort(sources);
|
||||
StreamSource best = sources.get(0);
|
||||
checkInterrupt();
|
||||
LOG.debug("Preview url for {} is {}", model.getName(), best.getMediaPlaylistUrl());
|
||||
video = new Media(best.getMediaPlaylistUrl());
|
||||
if(videoPlayer != null) {
|
||||
videoPlayer.dispose();
|
||||
|
@ -206,6 +207,7 @@ public class PreviewPopupHandler implements EventHandler<MouseEvent> {
|
|||
});
|
||||
}
|
||||
});
|
||||
videoPlayer.setOnError(() -> onError(videoPlayer));
|
||||
} catch (IllegalStateException e) {
|
||||
if(e.getMessage().equals("Stream url unknown")) {
|
||||
// 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) {
|
||||
preview.setFitWidth(w);
|
||||
preview.setFitHeight(h);
|
||||
|
|
Loading…
Reference in New Issue