Additional top-level classes in compilation unit: MediaPlayerShutdownHook, MediaTimerTask.
MediaPlayer class provides the controls for playing media.
It is used in combination with the Media and MediaView
classes to display and control media playback. MediaPlayer does
not contain any visual elements so must be used with the MediaView
class to view any video track which may be present.
MediaPlayer provides the pause(), play(),
stop() and seek() controls as
well as the rate and autoPlay
properties which apply to all types of media. It also provides the
balance, mute, and
volume properties which control audio playback
characteristics. Further control over audio quality may be attained via the
AudioEqualizer associated with the player. Frequency descriptors of
audio playback may be observed by registering an AudioSpectrumListener.
Information about playback position, rate, and buffering may be obtained from
the currentTime,
currentRate, and
bufferProgressTime
properties, respectively. Media marker notifications are received by an event
handler registered as the onMarker property.
For finite duration media, playback may be positioned at any point in time
between 0.0 and the duration of the media. MediaPlayer
refines this definition by adding the startTime and
stopTime
properties which in effect define a virtual media source with time position
constrained to [startTime,stopTime]. Media playback
commences at startTime and continues to stopTime.
The interval defined by these two endpoints is termed a cycle with
duration being the difference of the stop and start times. This cycle
may be set to repeat a specific or indefinite number of times. The total
duration of media playback is then the product of the cycle duration and the
number of times the cycle is played. If the stop time of the cycle is reached
and the cycle is to be played again, the event handler registered with the
onRepeat property is invoked. If the stop time is
reached, then the event handler registered with the onEndOfMedia
property is invoked regardless of whether the cycle is to be repeated or not.
A zero-relative index of which cycle is presently being played is maintained
by currentCount.
The operation of a MediaPlayer is inherently asynchronous.
A player is not prepared to respond to commands quasi-immediately until
its status has transitioned to Status#READY, which in
effect generally occurs when media pre-roll completes. Some requests made of
a player prior to its status being READY will however take
effect when that status is entered. These include invoking play()
without an intervening invocation of pause() or stop()
before the READY transition, as well as setting any of the
autoPlay, balance,
mute, rate,
startTime, stopTime, and
volume properties.
The status
property may be monitored to make the application aware of player status
changes, and callback functions may be registered via properties such as
onReady if an action should be taken when a particular status is
entered. There are also error and onError properties which
respectively enable monitoring when an error occurs and taking a specified
action in response thereto.
The same MediaPlayer object may be shared among multiple
MediaViews. This will not affect the player itself. In
particular, the property settings of the view will not have any effect on
media playback.
Media, MediaView
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | MediaPlayer.
Listener of marker events emitted by the implementation layer. |
| private class | |
| private class | |
| private class | |
| private class | |
| private class | |
| private class | |
| private class | |
| private class | |
| public static enum | MediaPlayer.
Enumeration describing the different status values of a |
| Modifier and Type | Field and Description |
|---|---|
| private AudioEqualizer | audioEqualizer
The read-only |
| private static final double | |
| private static final int | |
| private static final int | |
| private boolean | |
| private DoubleProperty | audioSpectrumInterval
The interval between spectrum updates in seconds. |
| private boolean | |
| private ObjectProperty | audioSpectrumListener
A listener for audio spectrum updates. |
| private IntegerProperty | audioSpectrumNumBands
The number of bands in the audio spectrum. |
| private boolean | |
| private IntegerProperty | audioSpectrumThreshold
The sensitivity threshold in decibels; must be non-positive. |
| private boolean | |
| private BooleanProperty | autoPlay
Whether playing should start as soon as possible. |
| private DoubleProperty | balance
The balance, or left-right setting, of the audio output. |
| private boolean | |
| private BufferListener | |
| private ReadOnlyObjectWrapper | bufferProgressTime
The current buffer position indicating how much media can be played
without stalling the |
| private ReadOnlyIntegerWrapper | currentCount
The number of completed playback cycles. |
| private ReadOnlyDoubleWrapper | currentRate
The current rate of playback regardless of settings. |
| private VideoDataBuffer | |
| private ReadOnlyObjectWrapper | currentTime
The current media playback time. |
| private IntegerProperty | cycleCount
The number of times the media will be played. |
| private ReadOnlyObjectWrapper | cycleDuration
The amount of time between the |
| private static final int | |
| private static final double | |
| private static final int | |
| private final Object | |
| private ReadOnlyObjectWrapper | error
Observable property set to a |
| private MediaErrorListener | |
| public static final int | INDEFINITE
A value representing an effectively infinite number of playback cycles. |
| private boolean | |
| private boolean | |
| private MediaPlayer | |
| private BufferProgressEvent | |
| private MarkerListener | |
| private MapChangeListener | |
| private Media | |
| private MediaTimerTask | |
| private BooleanProperty | mute
Whether the player audio is muted. |
| private boolean | |
| private VideoDataBuffer | |
| private ObjectProperty | onEndOfMedia
Event handler invoked when the player |
| private ObjectProperty | onError
Event handler invoked when an error occurs. |
| private ObjectProperty | onHalted
Event handler invoked when the status changes to |
| private ObjectProperty | onMarker
Event handler invoked when the player |
| private ObjectProperty | onPaused
Event handler invoked when the status changes to |
| private ObjectProperty | onPlaying
Event handler invoked when the status changes to
|
| private ObjectProperty | onReady
Event handler invoked when the status changes to
|
| private ObjectProperty | onRepeat
Event handler invoked when the player |
| private ObjectProperty | onStalled
Event handler invoked when the status changes to
|
| private ObjectProperty | onStopped
Event handler invoked when the status changes to
|
| private boolean | |
| private boolean | |
| private double | |
| private DoubleProperty | rate
The rate at which the media should be played. |
| private static final double | |
| private static final double | |
| private boolean | |
| private MediaPlayer. | |
| private final Object | |
| private VideoTrackSizeListener | |
| private AudioSpectrumListener | |
| private ObjectProperty | startTime
The time offset where media should start playing, or restart from when repeating. |
| private Duration | |
| private boolean | |
| private PlayerStateListener | |
| private ReadOnlyObjectWrapper | status
The current state of the MediaPlayer. |
| private ObjectProperty | stopTime
The time offset where media should stop playing or restart when repeating. |
| private boolean | |
| private PlayerTimeListener | |
| private ReadOnlyObjectWrapper | totalDuration
The total amount of play time if allowed to play until finished. |
| private final Set | |
| private DoubleProperty | volume
The volume at which the media should be played. |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public DoubleProperty | |
| public ObjectProperty | |
| public IntegerProperty | |
| public IntegerProperty | |
| public BooleanProperty | |
| public DoubleProperty | |
| public ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| private void | |
| private double[] | Returns: the clamped times in seconds as{actualStart, actualStop}.the new start time. startValue, Duration the new stop time. stopValue)Behaviorally clamp the start and stop times. |
| private void | |
| private static double | |
| private static int | |
| pack-priv void | |
| public ReadOnlyIntegerProperty | |
| private ReadOnlyIntegerWrapper | |
| public ReadOnlyDoubleProperty | |
| private ReadOnlyDoubleWrapper | |
| public ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| public IntegerProperty | |
| public ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| pack-priv void | |
| public synchronized void | |
| public ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| public final AudioEqualizer | Returns: theAudioEqualizer or null if player is disposed.Retrieve the |
| public final double | Returns: the spectral update intervalRetrieves the value of the audio spectrum notification interval in seconds. |
| public final AudioSpectrumListener | Returns: the spectral listener ornullRetrieves the listener of the audio spectrum. |
| public final int | Returns: the number of spectral bands.Retrieves the number of bands in the audio spectrum. |
| public final int | Returns: the spectral threshold in dBRetrieves the audio spectrum threshold in decibels. |
| public final double | |
| public final Duration | |
| public final int | |
| public final double | |
| public final Duration | |
| public final int | |
| public final Duration | |
| public final MediaException | |
| pack-priv VideoDataBuffer | Returns: the current frame to be used for rendering, or null if not in a render cycleWarning You must call releaseFrame() on the returned frame when you are finished with it or a massive memory leak will occur. |
| public final Media | |
| public final Runnable | |
| public final Runnable | |
| public final Runnable | |
| public final EventHandler | |
| public final Runnable | |
| public final Runnable | |
| public final Runnable | |
| public final Runnable | |
| public final Runnable | |
| public final Runnable | |
| public final double | |
| public final Duration | |
| public final MediaPlayer. | |
| public final Duration | |
| public final Duration | Returns: the total playback durationRetrieves the total playback duration including all cycles (repetitions). |
| public final double | |
| pack-priv void | |
| pack-priv void | |
| private void | |
| public final boolean | |
| public final boolean | |
| pack-priv void | |
| public BooleanProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public ObjectProperty | |
| public void | |
| public void | |
| pack-priv void | |
| public DoubleProperty | |
| pack-priv void | |
| pack-priv void | |
| pack-priv MediaPlayer | |
| public void | |
| public final void | setAudioSpectrumInterval(double
a positive value specifying the spectral update interval value)Sets the value of the audio spectrum notification interval in seconds. |
| public final void | setAudioSpectrumListener(AudioSpectrumListener
the spectral listener or listener)null.Sets the listener of the audio spectrum. |
| public final void | setAudioSpectrumNumBands(int
the number of spectral bands; value)valuemust be ≥ 2Sets the number of bands in the audio spectrum. |
| public final void | setAudioSpectrumThreshold(int
the spectral threshold in dB; must be ≤ value)0.Sets the audio spectrum threshold in decibels. |
| public final void | |
| public final void | |
| private void | |
| private void | |
| private void | |
| private void | |
| public final void | |
| private void | |
| private void | |
| public final void | |
| public final void | |
| public final void | setOnError(Runnable
the event handler or value)null.Sets the event handler to be called when an error occurs. |
| public final void | |
| public final void | setOnMarker(EventHandler<MediaMarkerEvent>
the marker event handler. onMarker)Sets the marker event handler. |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| public final void | |
| private void | setStartStopTimes(Duration
the new start time. startValue, boolean isStartValueSet, Duration the new stop time. stopValue, boolean isStopValueSet)Set the effective start and stop times on the underlying player, clamping as needed. |
| public final void | |
| private void | |
| public final void | |
| private void | |
| public final void | |
| public ObjectProperty | |
| public ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| public void | |
| public ObjectProperty | |
| public ReadOnlyObjectProperty | |
| private ReadOnlyObjectWrapper | |
| pack-priv void | |
| public DoubleProperty |