How do I play an alert sound in Java FX 2? Is there a way of using the OS default notification sound?
This is how I play sounds,
private void playMedia(Media m){
if (m != null){
MediaPlayer mp = new MediaPlayer(m);
mp.play();
}
}
public void playSomeSound(){
try{
Media someSound = new Media(getClass().getResource("some-sound.mp3").toString());
playMedia(someSound);
}catch(Exception ex){
GeeLogger.error(getClass(), ex.getLocalizedMessage(), ex);
}
}
Don't know about SO specifics though. Hope it helps.