class JavaFxMediaPlayer extends java.lang.Object implements SoundPlayer
Modifier and Type | Field and Description |
---|---|
private ListenerList<AudioListener> |
listeners |
private javafx.scene.media.MediaPlayer |
mediaPlayer |
Constructor and Description |
---|
JavaFxMediaPlayer() |
Modifier and Type | Method and Description |
---|---|
void |
addAudioListener(AudioListener listener)
Adds a listener that will be notified of audio playback events.
|
static void |
initFxPlatform()
Initializes the JavaFX platform runtime.
|
void |
pause(AudioPlayer.Execute command,
AudioPlayer.State stateChange,
java.net.URL playingUrl)
Ask player to pause the current playing media.
|
void |
play(AudioPlayer.Execute command,
AudioPlayer.State stateChange,
java.net.URL playingUrl)
Ask player to play a new media.
|
boolean |
playing(AudioPlayer.Execute command)
Method called when a media is being played.
|
double |
position()
Returns the media playback position, in seconds.
|
double |
speed()
Returns the media playback speed ratio.
|
private final ListenerList<AudioListener> listeners
private javafx.scene.media.MediaPlayer mediaPlayer
JavaFxMediaPlayer() throws JosmRuntimeException
JosmRuntimeException
public static void initFxPlatform() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the current thread is interrupted while waitingpublic void play(AudioPlayer.Execute command, AudioPlayer.State stateChange, java.net.URL playingUrl) throws AudioException, java.io.IOException
SoundPlayer
play
in interface SoundPlayer
command
- Command containing media informationstateChange
- the previous stateplayingUrl
- the currently playing URL, if anyAudioException
- if an audio error occursjava.io.IOException
- if an I/O error occurspublic void pause(AudioPlayer.Execute command, AudioPlayer.State stateChange, java.net.URL playingUrl) throws AudioException, java.io.IOException
SoundPlayer
pause
in interface SoundPlayer
command
- Command containing media informationstateChange
- the previous stateplayingUrl
- the currently playing URL, if anyAudioException
- if an audio error occursjava.io.IOException
- if an I/O error occurspublic boolean playing(AudioPlayer.Execute command) throws AudioException, java.io.IOException, java.lang.InterruptedException
SoundPlayer
playing
in interface SoundPlayer
command
- Command containing media informationtrue
if the playing call was blocking, and the playback is finished when this method returnsAudioException
- if an audio error occursjava.io.IOException
- if an I/O error occursjava.lang.InterruptedException
- if the play is interruptedpublic double position()
SoundPlayer
position
in interface SoundPlayer
public double speed()
SoundPlayer
speed
in interface SoundPlayer
public void addAudioListener(AudioListener listener)
SoundPlayer
addAudioListener
in interface SoundPlayer
listener
- audio listener