I'm experimenting with JavaFX making a small game.
I want to add sound. How?
I tried MediaPlayer
with media
defined with relative source
attribute like:
attribute media = Media{
source: "{__FILE__}/sound/hormpipe.mp3"
}
attribute player = MediaPlayer{
autoPlay:true
media:media
}
It doesn't play. I get
FX Media Object caught Exception com.sun.media.jmc.MediaUnavailableException: Media unavailable: file: ... Sound.class/sound/hormpipe.mp3
This worked for me:
Source file should be in project's root directory (not src, not dist).