Package javafx.scene.media
Class MediaPlayer
java.lang.Object
javafx.scene.media.MediaPlayer
- Author:
- Bruno Salmon
-
Property Summary
PropertiesTypePropertyDescriptionEvent handler invoked when the status changes toHALTED.Event handler invoked when the status changes toPAUSED.Event handler invoked when the status changes toPLAYING.Event handler invoked when the status changes toREADY.Event handler invoked when the playercurrentTimereachesstopTimeand will be repeating.Event handler invoked when the status changes toSTALLED.Event handler invoked when the status changes toSTOPPED. -
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration describing the different status values of aMediaPlayer. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()final DurationGets the value of thecurrentTimeproperty.intgetMedia()final RunnableRetrieves the end of media event handler.final RunnableRetrieves theMediaPlayer.Status.HALTEDevent handler.final RunnableRetrieves theMediaPlayer.Status.PAUSEDevent handler.final RunnableRetrieves theMediaPlayer.Status.PLAYINGevent handler.final RunnableRetrieves theMediaPlayer.Status.READYevent handler.final RunnableRetrieves the repeat event handler.final RunnableRetrieves theMediaPlayer.Status.STALLEDevent handler.final RunnableRetrieves theMediaPlayer.Status.STOPPEDevent handler.getPeer()Gets the value of thestatusproperty.Event handler invoked when the status changes toHALTED.Event handler invoked when the status changes toPAUSED.Event handler invoked when the status changes toPLAYING.Event handler invoked when the status changes toREADY.Event handler invoked when the playercurrentTimereachesstopTimeand will be repeating.Event handler invoked when the status changes toSTALLED.Event handler invoked when the status changes toSTOPPED.voidpause()voidplay()voidfinal voidsetAudioSpectrumInterval(double value) Sets the value of the audio spectrum notification interval in seconds.final voidfinal voidsetAudioSpectrumNumBands(int value) Sets the number of bands in the audio spectrum.voidsetCycleCount(int cycleCount) final voidsetMute(boolean mute) Sets the value of themuteproperty.final voidsetOnEndOfMedia(Runnable value) Sets the end of media event handler.final voidsetOnHalted(Runnable value) Sets theMediaPlayer.Status.HALTEDevent handler.final voidsetOnPaused(Runnable value) Sets theMediaPlayer.Status.PAUSEDevent handler.final voidsetOnPlaying(Runnable value) Sets theMediaPlayer.Status.PLAYINGevent handler.final voidsetOnReady(Runnable value) Sets theMediaPlayer.Status.READYevent handler.final voidsetOnRepeat(Runnable value) Sets the repeat event handler.final voidsetOnStalled(Runnable value) Sets theMediaPlayer.Status.STALLEDevent handler.final voidsetOnStopped(Runnable value) Sets theMediaPlayer.Status.STOPPEDevent handler.voidsetStatus(MediaPlayer.Status status) Sets the value of thestatusproperty.voidsetVolume(double volume) voidstop()
-
Property Details
-
mute
- See Also:
-
currentTime
- See Also:
-
status
-
onEndOfMedia
-
onReady
Event handler invoked when the status changes toREADY. -
onPlaying
Event handler invoked when the status changes toPLAYING. -
onPaused
Event handler invoked when the status changes toPAUSED. -
onStopped
Event handler invoked when the status changes toSTOPPED. -
onHalted
Event handler invoked when the status changes toHALTED. -
onRepeat
Event handler invoked when the playercurrentTimereachesstopTimeand will be repeating. This callback is made prior to seeking back tostartTime. -
onStalled
Event handler invoked when the status changes toSTALLED.
-
-
Field Details
-
INDEFINITE
public static final int INDEFINITE- See Also:
-
-
Constructor Details
-
MediaPlayer
-
-
Method Details
-
getPeer
-
getMedia
-
setCycleCount
public void setCycleCount(int cycleCount) -
getCycleCount
public int getCycleCount() -
play
public void play() -
pause
public void pause() -
stop
public void stop() -
dispose
public void dispose() -
setVolume
public void setVolume(double volume) -
muteProperty
- Returns:
- the
muteproperty - See Also:
-
setMute
public final void setMute(boolean mute) Sets the value of themuteproperty.- Property description:
- Parameters:
mute- the value for themuteproperty- See Also:
-
currentTimeProperty
- Returns:
- the
currentTimeproperty - See Also:
-
getCurrentTime
Gets the value of thecurrentTimeproperty.- Property description:
- Returns:
- the value of the
currentTimeproperty - See Also:
-
seek
-
setAudioSpectrumInterval
public final void setAudioSpectrumInterval(double value) Sets the value of the audio spectrum notification interval in seconds.- Parameters:
value- a positive value specifying the spectral update interval
-
setAudioSpectrumNumBands
public final void setAudioSpectrumNumBands(int value) Sets the number of bands in the audio spectrum.- Parameters:
value- the number of spectral bands;valuemust be ≥ 2
-
setAudioSpectrumListener
-
statusProperty
- Returns:
- the
statusproperty - See Also:
-
getStatus
Gets the value of thestatusproperty.- Property description:
- Returns:
- the value of the
statusproperty - See Also:
-
setOnEndOfMedia
Sets the end of media event handler.- Parameters:
value- the event handler ornull.
-
getOnEndOfMedia
Retrieves the end of media event handler.- Returns:
- the event handler or
null.
-
onEndOfMediaProperty
- Returns:
- the
onEndOfMediaproperty - See Also:
-
setOnReady
Sets theMediaPlayer.Status.READYevent handler.- Parameters:
value- the event handler ornull.
-
getOnReady
Retrieves theMediaPlayer.Status.READYevent handler.- Returns:
- the event handler or
null.
-
onReadyProperty
Event handler invoked when the status changes toREADY.- Returns:
- the
onReadyproperty - See Also:
-
setOnPlaying
Sets theMediaPlayer.Status.PLAYINGevent handler.- Parameters:
value- the event handler ornull.
-
getOnPlaying
Retrieves theMediaPlayer.Status.PLAYINGevent handler.- Returns:
- the event handler or
null.
-
onPlayingProperty
Event handler invoked when the status changes toPLAYING.- Returns:
- the
onPlayingproperty - See Also:
-
setOnPaused
Sets theMediaPlayer.Status.PAUSEDevent handler.- Parameters:
value- the event handler ornull.
-
getOnPaused
Retrieves theMediaPlayer.Status.PAUSEDevent handler.- Returns:
- the event handler or
null.
-
onPausedProperty
Event handler invoked when the status changes toPAUSED.- Returns:
- the
onPausedproperty - See Also:
-
setOnStopped
Sets theMediaPlayer.Status.STOPPEDevent handler.- Parameters:
value- the event handler ornull.
-
getOnStopped
Retrieves theMediaPlayer.Status.STOPPEDevent handler.- Returns:
- the event handler or
null.
-
onStoppedProperty
Event handler invoked when the status changes toSTOPPED.- Returns:
- the
onStoppedproperty - See Also:
-
setOnHalted
Sets theMediaPlayer.Status.HALTEDevent handler.- Parameters:
value- the event handler ornull.
-
getOnHalted
Retrieves theMediaPlayer.Status.HALTEDevent handler.- Returns:
- the event handler or
null.
-
onHaltedProperty
Event handler invoked when the status changes toHALTED.- Returns:
- the
onHaltedproperty - See Also:
-
setOnRepeat
Sets the repeat event handler.- Parameters:
value- the event handler ornull.
-
getOnRepeat
Retrieves the repeat event handler.- Returns:
- the event handler or
null.
-
onRepeatProperty
Event handler invoked when the playercurrentTimereachesstopTimeand will be repeating. This callback is made prior to seeking back tostartTime.- Returns:
- the
onRepeatproperty - See Also:
-
setOnStalled
Sets theMediaPlayer.Status.STALLEDevent handler.- Parameters:
value- the event handler ornull.
-
getOnStalled
Retrieves theMediaPlayer.Status.STALLEDevent handler.- Returns:
- the event handler or
null.
-
onStalledProperty
Event handler invoked when the status changes toSTALLED.- Returns:
- the
onStalledproperty - See Also:
-
setStatus
Sets the value of thestatusproperty.- Property description:
- Parameters:
status- the value for thestatusproperty- See Also:
-