B4J Question Exception using MediaPlayer

Computersmith64

Well-Known Member
Licensed User
Longtime User
I'm having an issue with MediaPlayer where if I try to play a sound, it works perfectly in debug mode - however if I do a release build & run it I get the following exception:
MediaException: UNKNOWN : [com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer@5c13eb0e] 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)

Here's the code I use:
B4X:
    Private MP As MediaPlayer
    MP.Initialize("", File.GetUri(File.DirAssets, "roll.wav"))
    MP.Stop
    MP.Play

I've done some searching on the web & found a few references to this issue, however I haven't been able to find a fix. Any suggestions?

- Colin.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Check the documentation:

SS-2017-12-01_08.11.17.png


The only workaround is to copy it to a different folder (File.DirData).
 
Upvote 0
Top