How do I play an alert sound in Java FX 2? Is there a way of using the OS default notification sound?
相关问题
- Can we recover audio from MFCC coefficients?
- Is there a way to play audio on a mobile browser w
- How to properly use Weld in JavaFX 2 application?
- Is it possible to know the duration of an MP3 befo
- Playing specific system sound with Qt
相关文章
- Android Visualizer class throwing runtime exceptio
- WP7 Alert dialog
- How to show appropriate icon on dialog box
- Simulate Microphone (virtual mic)
- Android Studio Mediaplayer how to fade in and out
- Detect or Approximate Bluetooth Latency on Android
- How to change the color of pane in javafx?
- TableView has more columns than specified
This is how I play sounds,
Don't know about SO specifics though. Hope it helps.
Play a sound with pure JavaFX
Simply use an instance of
AudioClip
. This one is very suitable for just playing single short sounds.Play a default notification sound
Concerning Windows OS there is a way accessing properties via
java.awt.Toolkit
. A returned sound property is a simpleRunnable
which can be fired directly without any worries about sound sources etc.Use the example below to see how both options work (you have to add 'alert.wav' to your src folder).
There is currently nothing in JavaFX itself to access the OS default alert sound (you can use JavaFX to trigger on events to play back fire and forget audioclips as well as tracked media audio like mp3s).
There is an open feature request: RT-21634 (anybody can signup to view the jira).
You can beep via awt:
Printing a beep character, nicely named 007 should work according to google searches, but does not on my machine - I guess it accesses a buzzer in the machine rather than the speaker system and my machine must not have the buzzer connected or enabled.