In a previous post Watchdog timer for mediaplayer I successfully sought assistance in implementing a watchdog timer as a means of stepping through a MediaException error thrown by MediaPlayer so the application didn't stall, allowing subsequent videos to play after the watchdog timer expired.
However it seems the error is thrown randomly in that in most cases for the same set of video files no error is thrown, but occasionally one or two different videos don't play and so I don't believe there is anything wrong with the video files as such. I have also investigated a pre-loading technique used in this post Media exception error which I thought may help, but it's rather difficult to implement in my situation.
So I would like to revisit the problem and try to catch the error so I could retry to play the video file rather than show a blank screen for the period of the watchdog timer before playing the next video file in sequence.
Here is an example of what I see in the logs when an error occurs:
BDSSynergyPlayerBoard V12b started at 13/6/2023 21:6:53
Java version: 18.0.1
Host Address: 192.168.0.10
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@31fd1d64] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at [email protected]/javafx.scene.media.MediaException.getMediaException(MediaException.java:161)
at [email protected]/javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2624)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)
Video error for #9
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@62a64577] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at [email protected]/javafx.scene.media.MediaException.getMediaException(MediaException.java:161)
at [email protected]/javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2624)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)
Video error for #20
The first 3 lines are just my standard log entries and the Video error lines are logged when the watchdog timer expires.
I thought I should be able to capture the MediaException errors by using a Try / Catch / End Try around the MediaPlayer code so I could then implement retry code, but it does not appear to capture the error.
Why is it that the MediaException shows in red text in the logs, but a Try / Catch / End Try doesn't capture the exception? In any event, how can I capture the MediaException so I can implement some retry code?
Thanks in anticipation of any assistance.
However it seems the error is thrown randomly in that in most cases for the same set of video files no error is thrown, but occasionally one or two different videos don't play and so I don't believe there is anything wrong with the video files as such. I have also investigated a pre-loading technique used in this post Media exception error which I thought may help, but it's rather difficult to implement in my situation.
So I would like to revisit the problem and try to catch the error so I could retry to play the video file rather than show a blank screen for the period of the watchdog timer before playing the next video file in sequence.
Here is an example of what I see in the logs when an error occurs:
BDSSynergyPlayerBoard V12b started at 13/6/2023 21:6:53
Java version: 18.0.1
Host Address: 192.168.0.10
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@31fd1d64] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at [email protected]/javafx.scene.media.MediaException.getMediaException(MediaException.java:161)
at [email protected]/javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2624)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)
Video error for #9
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@62a64577] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at [email protected]/javafx.scene.media.MediaException.getMediaException(MediaException.java:161)
at [email protected]/javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2624)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:692)
at [email protected]/com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:426)
Video error for #20
The first 3 lines are just my standard log entries and the Video error lines are logged when the watchdog timer expires.
I thought I should be able to capture the MediaException errors by using a Try / Catch / End Try around the MediaPlayer code so I could then implement retry code, but it does not appear to capture the error.
Why is it that the MediaException shows in red text in the logs, but a Try / Catch / End Try doesn't capture the exception? In any event, how can I capture the MediaException so I can implement some retry code?
Thanks in anticipation of any assistance.