B4J Question Media exception error

Olivier Zeegers

Member
Licensed User
Hello, I get this error when playing VIDEO files..

MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@71738f0] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)

I've looked at this thread https://www.b4x.com/android/forum/threads/exception-using-mediaplayer.86736/#content

but in my case it happens when playing video files.
The strange thing is that the first 10 times videos are played every goes fine, but after that the error comes up....

Any clue ?

I need to have my program running next thursday some I am getting a little nervous ;-)

thanx !!
 

Olivier Zeegers

Member
Licensed User
Yes I think so... I logged the videonumber and it happens with different videos

B4X:
6
3
1
6
4
5
8
6
8
7
4
1
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@10dae0c] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
6
1
8
6
1
7
2
8
4
8
1
3
4
3
8
4
6
7
6
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@11e55039] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
5
 
Upvote 0

Olivier Zeegers

Member
Licensed User
When I restrict the program to only play the first 3 videos it gives error randomly with video2 and video3...

B4X:
2
1
2
2
1
2
2
3
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@2845fb24] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
1
3
2
2
2
1
2
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@475b0ffb] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
3
3
2
3
1
2
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@6f38ce9e] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
2
2
ozeege

When I let play the videos 4 to 7 it gives error on random videos as well:

B4X:
6
5
5
6
6
6
4
6
4
6
6
6
5
6
5
6
5
5
4
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@150a8a58] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
6
5
6
6
5
6
4
6
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@6719abc3] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
5
 
Upvote 0

Olivier Zeegers

Member
Licensed User
Ok, I made a test app which displays the fire background video in loop....
When mouse is clicked a random video effect is played, when this effect has finished the fire loop is shown again.
The videos I used are in this file: www.zeegers.be/Donkerrun.zip

When an effect is playing while clicking on the mouse, the effect should stop and the next effect should play...
You see in the log the number off effect is being played, and when it is finished.... Randomly the exception comes in..

thank you for your help, we are expecting 1200 runners so I am a little nervous... :eek::cool::(
 

Attachments

  • testexport.zip
    2 KB · Views: 213
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
Try this - note you will have to edit the file paths as I put the videos in FileDirAssets (the files folder)

I could not get it to break, even after frantic clicking on the mainform.
 

Attachments

  • tryThis.zip
    1.8 KB · Views: 253
Upvote 0

Olivier Zeegers

Member
Licensed User
Hi Daestrum !

Yes !! the errors are gone ! yippee!!!

Where is the kuddos button ? haha THANK YOU !!

But the fire does not loop ? although you set cyclecount to false...
And after an effect is played the fire does not restart....

Don't understand this.... in my version the cyclecount works....
 
Upvote 0

Olivier Zeegers

Member
Licensed User
when I add the sub

sub fire_complete()
log("fire complete")
end sub

it does not reach this sub.... the fire video stops but does not complete ?
 
Upvote 0

Olivier Zeegers

Member
Licensed User
in debug mode the programs goes into the complete subs and works like it should be
also the fire plays in loop in debug mode

but then there's is a mediaplayer exception again !

B4X:
effect completed
fire completed
fire completed
fire completed
fire completed
fire completed
fire completed
fire completed
effect8
effect completed
fire completed
effect3
effect2
previous effect stopped
effect6
previous effect stopped
effect7
previous effect stopped
effect6
previous effect stopped
effect1
previous effect stopped
effect8
previous effect stopped
effect7
previous effect stopped
effect3
previous effect stopped
effect completed
effect8
effect6
previous effect stopped
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@1f2ffdd2] ERROR_MEDIA_INVALID: ERROR_MEDIA_INVALID
    at javafx.scene.media.MediaException.getMediaException(MediaException.java:160)
    at javafx.scene.media.MediaPlayer$_MediaErrorListener.onError(MediaPlayer.java:2615)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.HandleErrorEvents(NativeMediaPlayer.java:691)
    at com.sun.media.jfxmediaimpl.NativeMediaPlayer$EventQueueThread.run(NativeMediaPlayer.java:425)
effect6
previous effect stopped
effect completed
fire completed
fire completed
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
How often are you actually clicking?

If you are clicking as fast as you can, of course it will break, you will simply screw up the event queue.

Put a check in the mainform_click so you can only click once a second, this seems to be tolerated by the event queue.

Any faster and things stop working, like the fire not looping.
 
Upvote 0

Olivier Zeegers

Member
Licensed User
I was not clicking fast, that is the problem. Just clicking after the effect has faded.

In release mode no error occurs but the fire does not loop and the complete events are not fired.

In debug mode thus works but I get the same media exception and when leaving the fire effect for a long time without clicking the program hangs completely..
 
Upvote 0

Olivier Zeegers

Member
Licensed User


Yes really desperate !

I already looked to you post before but thought that it would display a layer with controls and not a full screen video effect..
Tomorrow I work from 0800-1900.. After that I will give it a try...
Can you maybe try to reproduce my test app with your wrapper ?

Thank you already for your tip and help!!
 
Upvote 0

moster67

Expert
Licensed User
Longtime User
I modified @Daestrum's sample-project and I didn't get any more errors and it seems to work fine in release-mode.
I made some few changes, such as stopping firebackground instead of pausing it.
I think the important thing is though that the media-files should be in the DirData-folder (see the docs).
 

Attachments

  • testMike.zip
    2 KB · Views: 211
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Another version. It's a little bit of a re-write.
1) I'm pre-loading all the media you want to play into an array. That seems to solve most of the continuous click problems.
2) Another issue was that you were not stopping your effects. That allowed for multiple effect_complete calls on effects that you wiped out with re-initializing your effect variable. Since this is a global variable, you were encountering some trashing.
3) Re-initializing the effectv variable constantly caused some other errors (Null pointer) when fast clicking. This was solved by first creating another JavaObject, initializing it and then assigning it to effectv.
4) In my case, since I'm pre-loading the media files, the location of the files does not seem to matter.
5) I did some code consolidation by adding two new subs: LoadEffect and SwitchEffect
6) Used some flags to ensure that events do not trample over each other
7) Change MAXEFFECTS to the number of effect##.mp4 files you have
8) Change effectsFolder to the location of the effect##.mp4 file and the fire.mp4 file.

Enjoy your event!
 

Attachments

  • testOliver.zip
    2.4 KB · Views: 209
Upvote 0

Olivier Zeegers

Member
Licensed User
I modified @Daestrum's sample-project and I didn't get any more errors and it seems to work fine in release-mode.
I made some few changes, such as stopping firebackground instead of pausing it.
I think the important thing is though that the media-files should be in the DirData-folder (see the docs).
Super !! Many thanks!! I'll be checking tonight! Now on my way to another day at the office, I am an orthopedic surgeon in real life so during the day not much time..
 
Upvote 0

Olivier Zeegers

Member
Licensed User
Another version. It's a little bit of a re-write.
1) I'm pre-loading all the media you want to play into an array. That seems to solve most of the continuous click problems.
2) Another issue was that you were not stopping your effects. That allowed for multiple effect_complete calls on effects that you wiped out with re-initializing your effect variable. Since this is a global variable, you were encountering some trashing.
3) Re-initializing the effectv variable constantly caused some other errors (Null pointer) when fast clicking. This was solved by first creating another JavaObject, initializing it and then assigning it to effectv.
4) In my case, since I'm pre-loading the media files, the location of the files does not seem to matter.
5) I did some code consolidation by adding two new subs: LoadEffect and SwitchEffect
6) Used some flags to ensure that events do not trample over each other
7) Change MAXEFFECTS to the number of effect##.mp4 files you have
8) Change effectsFolder to the location of the effect##.mp4 file and the fire.mp4 file.

Enjoy your event!
Fantastic!! Will check tonight!! Many many thanks!!

Olivier
 
Upvote 0
Top