As JavaFX is not only a UI-Toolkit but also provides a “fullblow” multimedia stack you can play sound files and videos without residing to other APIs/Libraries. Unfortunately you can not feed any URL into it.
Only the following protocols are supported
- http:
- file:
- jar:file:
For most developers those protocols are enough but if you are running in an Equinox-OSGi-Environment and want to play a sound file packaged with in your bundle you are in trouble because the URL you’ll get is eg on Equinox bundleresource://....
so you can’t directly pass this URL to the JavaFX Media API because it will fail to resolve the resource.
Even if you know how to fix this and translate the URL to one of the above protocols your business code should never have a direct dependency on OSGi so you can not deal with this problem yourself but need a library to do this.
One of our JavaFX customers (360T) approach us a few days ago and so we implemented API giving you exactly this feature and you can/should always create Media instance like this:
public void playSound() { URL url = getClass().getResource("mysound.mp3"); MediaLoader.createMedia( url ) .map( MediaPlayer::new ) .ifPresent( MediaPlayer::play ); }
If you are interested in other new features of 2.2.0 look at this overview page
Pingback: e(fx)clipse 2.2.0 – New features overview | Tomsondev Blog
On the
http://www.eclipse.org/efxclipse/releases.html
webpage there is the following broken link
https://tomsondev.bestsolution.at/2015/09/03/efxclipse-2-1-0-released
Thanks i fixed the link