Class MediaPlayerBuilder
MediaPlayerBuilder class constructs instances of the MediaPlayer class
and offers a fluent interface for creating and configuring it.
This class includes a static create method that accepts the same arguments as the original MediaPlayer constructor
and returns an instance of the MediaPlayerBuilder.
You can use method chaining to call the builder methods for configuring the MediaPlayer.
Finally, invoke the build method to generate an instance of the MediaPlayer class.
Note that intermediate builder methods are not evaluated until the build method
is called, meaning they are evaluated lazily.
- Author:
- Hidekazu Kubota <hidekazu.kubota@gmail.com>
-
Method Summary
Modifier and TypeMethodDescriptionapply(Consumer<MediaPlayer> func) Applies a function to the MediaPlayer instance being constructed.audioSpectrumInterval(double value) A builder method that invokes thesetAudioSpectrumIntervalmethod on the instance being constructed.Applies a function to theaudioSpectrumIntervalPropertyof the instance being constructed.audioSpectrumListener(AudioSpectrumListener listener) A builder method that invokes thesetAudioSpectrumListenermethod on the instance being constructed.Applies a function to theaudioSpectrumListenerPropertyof the instance being constructed.audioSpectrumNumBands(int value) A builder method that invokes thesetAudioSpectrumNumBandsmethod on the instance being constructed.Applies a function to theaudioSpectrumNumBandsPropertyof the instance being constructed.audioSpectrumThreshold(int value) A builder method that invokes thesetAudioSpectrumThresholdmethod on the instance being constructed.Applies a function to theaudioSpectrumThresholdPropertyof the instance being constructed.autoPlay(boolean value) A builder method that invokes thesetAutoPlaymethod on the instance being constructed.Applies a function to theautoPlayPropertyof the instance being constructed.balance(double value) A builder method that invokes thesetBalancemethod on the instance being constructed.Applies a function to thebalancePropertyof the instance being constructed.Applies a function to thebufferProgressTimePropertyof the instance being constructed.build()Builds and returns an instance of theMediaPlayerclass.static MediaPlayerBuilderAccepts the constructor arguments ofMediaPlayer(Media)and returns an instance ofMediaPlayerBuilder.Applies a function to thecurrentCountPropertyof the instance being constructed.Applies a function to thecurrentRatePropertyof the instance being constructed.Applies a function to thecurrentTimePropertyof the instance being constructed.cycleCount(int value) A builder method that invokes thesetCycleCountmethod on the instance being constructed.Applies a function to thecycleCountPropertyof the instance being constructed.Applies a function to thecycleDurationPropertyof the instance being constructed.Applies a function to theerrorPropertyof the instance being constructed.mute(boolean value) A builder method that invokes thesetMutemethod on the instance being constructed.Applies a function to themutePropertyof the instance being constructed.onEndOfMedia(Runnable value) A builder method that invokes thesetOnEndOfMediamethod on the instance being constructed.Applies a function to theonEndOfMediaPropertyof the instance being constructed.A builder method that invokes thesetOnErrormethod on the instance being constructed.Applies a function to theonErrorPropertyof the instance being constructed.A builder method that invokes thesetOnHaltedmethod on the instance being constructed.Applies a function to theonHaltedPropertyof the instance being constructed.onMarker(EventHandler<MediaMarkerEvent> onMarker) A builder method that invokes thesetOnMarkermethod on the instance being constructed.Applies a function to theonMarkerPropertyof the instance being constructed.A builder method that invokes thesetOnPausedmethod on the instance being constructed.Applies a function to theonPausedPropertyof the instance being constructed.A builder method that invokes thesetOnPlayingmethod on the instance being constructed.Applies a function to theonPlayingPropertyof the instance being constructed.A builder method that invokes thesetOnReadymethod on the instance being constructed.Applies a function to theonReadyPropertyof the instance being constructed.A builder method that invokes thesetOnRepeatmethod on the instance being constructed.Applies a function to theonRepeatPropertyof the instance being constructed.A builder method that invokes thesetOnStalledmethod on the instance being constructed.Applies a function to theonStalledPropertyof the instance being constructed.A builder method that invokes thesetOnStoppedmethod on the instance being constructed.Applies a function to theonStoppedPropertyof the instance being constructed.rate(double value) A builder method that invokes thesetRatemethod on the instance being constructed.Applies a function to theratePropertyof the instance being constructed.A builder method that invokes thesetStartTimemethod on the instance being constructed.Applies a function to thestartTimePropertyof the instance being constructed.Applies a function to thestatusPropertyof the instance being constructed.A builder method that invokes thesetStopTimemethod on the instance being constructed.Applies a function to thestopTimePropertyof the instance being constructed.Applies a function to thetotalDurationPropertyof the instance being constructed.volume(double value) A builder method that invokes thesetVolumemethod on the instance being constructed.Applies a function to thevolumePropertyof the instance being constructed.
-
Method Details
-
create
Accepts the constructor arguments ofMediaPlayer(Media)and returns an instance ofMediaPlayerBuilder.- Returns:
- an instance of the
MediaPlayerBuilder.
-
build
Builds and returns an instance of theMediaPlayerclass.Intermediate builder methods are not evaluated until the
buildmethod is called; in other words, they are evaluated lazily.- Returns:
- new instance of the
MediaPlayerclass
-
apply
Applies a function to the MediaPlayer instance being constructed. Most operations on the instance can be performed using this method.- Returns:
- builder instance
-
audioSpectrumInterval
A builder method that invokes thesetAudioSpectrumIntervalmethod on the instance being constructed.- Returns:
- builder instance
-
audioSpectrumListener
A builder method that invokes thesetAudioSpectrumListenermethod on the instance being constructed.- Returns:
- builder instance
-
audioSpectrumNumBands
A builder method that invokes thesetAudioSpectrumNumBandsmethod on the instance being constructed.- Returns:
- builder instance
-
audioSpectrumThreshold
A builder method that invokes thesetAudioSpectrumThresholdmethod on the instance being constructed.- Returns:
- builder instance
-
autoPlay
A builder method that invokes thesetAutoPlaymethod on the instance being constructed.- Returns:
- builder instance
-
balance
A builder method that invokes thesetBalancemethod on the instance being constructed.- Returns:
- builder instance
-
cycleCount
A builder method that invokes thesetCycleCountmethod on the instance being constructed.- Returns:
- builder instance
-
mute
A builder method that invokes thesetMutemethod on the instance being constructed.- Returns:
- builder instance
-
onEndOfMedia
A builder method that invokes thesetOnEndOfMediamethod on the instance being constructed.- Returns:
- builder instance
-
onError
A builder method that invokes thesetOnErrormethod on the instance being constructed.- Returns:
- builder instance
-
onHalted
A builder method that invokes thesetOnHaltedmethod on the instance being constructed.- Returns:
- builder instance
-
onMarker
A builder method that invokes thesetOnMarkermethod on the instance being constructed.- Returns:
- builder instance
-
onPaused
A builder method that invokes thesetOnPausedmethod on the instance being constructed.- Returns:
- builder instance
-
onPlaying
A builder method that invokes thesetOnPlayingmethod on the instance being constructed.- Returns:
- builder instance
-
onReady
A builder method that invokes thesetOnReadymethod on the instance being constructed.- Returns:
- builder instance
-
onRepeat
A builder method that invokes thesetOnRepeatmethod on the instance being constructed.- Returns:
- builder instance
-
onStalled
A builder method that invokes thesetOnStalledmethod on the instance being constructed.- Returns:
- builder instance
-
onStopped
A builder method that invokes thesetOnStoppedmethod on the instance being constructed.- Returns:
- builder instance
-
rate
A builder method that invokes thesetRatemethod on the instance being constructed.- Returns:
- builder instance
-
startTime
A builder method that invokes thesetStartTimemethod on the instance being constructed.- Returns:
- builder instance
-
stopTime
A builder method that invokes thesetStopTimemethod on the instance being constructed.- Returns:
- builder instance
-
volume
A builder method that invokes thesetVolumemethod on the instance being constructed.- Returns:
- builder instance
-
audioSpectrumIntervalPropertyApply
Applies a function to theaudioSpectrumIntervalPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.audioSpectrumIntervalProperty().bind(anotherProperty)) // Use shorthand form .audioSpectrumIntervalPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
audioSpectrumListenerPropertyApply
public MediaPlayerBuilder audioSpectrumListenerPropertyApply(Consumer<ObjectProperty<AudioSpectrumListener>> op) Applies a function to theaudioSpectrumListenerPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.audioSpectrumListenerProperty().bind(anotherProperty)) // Use shorthand form .audioSpectrumListenerPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
audioSpectrumNumBandsPropertyApply
Applies a function to theaudioSpectrumNumBandsPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.audioSpectrumNumBandsProperty().bind(anotherProperty)) // Use shorthand form .audioSpectrumNumBandsPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
audioSpectrumThresholdPropertyApply
Applies a function to theaudioSpectrumThresholdPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.audioSpectrumThresholdProperty().bind(anotherProperty)) // Use shorthand form .audioSpectrumThresholdPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
autoPlayPropertyApply
Applies a function to theautoPlayPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.autoPlayProperty().bind(anotherProperty)) // Use shorthand form .autoPlayPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
balancePropertyApply
Applies a function to thebalancePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.balanceProperty().bind(anotherProperty)) // Use shorthand form .balancePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
bufferProgressTimePropertyApply
public MediaPlayerBuilder bufferProgressTimePropertyApply(Consumer<ReadOnlyObjectProperty<Duration>> op) Applies a function to thebufferProgressTimePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.bufferProgressTimeProperty().bind(anotherProperty)) // Use shorthand form .bufferProgressTimePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
currentCountPropertyApply
Applies a function to thecurrentCountPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.currentCountProperty().bind(anotherProperty)) // Use shorthand form .currentCountPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
currentRatePropertyApply
Applies a function to thecurrentRatePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.currentRateProperty().bind(anotherProperty)) // Use shorthand form .currentRatePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
currentTimePropertyApply
Applies a function to thecurrentTimePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.currentTimeProperty().bind(anotherProperty)) // Use shorthand form .currentTimePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
cycleCountPropertyApply
Applies a function to thecycleCountPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.cycleCountProperty().bind(anotherProperty)) // Use shorthand form .cycleCountPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
cycleDurationPropertyApply
Applies a function to thecycleDurationPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.cycleDurationProperty().bind(anotherProperty)) // Use shorthand form .cycleDurationPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
errorPropertyApply
Applies a function to theerrorPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.errorProperty().bind(anotherProperty)) // Use shorthand form .errorPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
mutePropertyApply
Applies a function to themutePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.muteProperty().bind(anotherProperty)) // Use shorthand form .mutePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onEndOfMediaPropertyApply
Applies a function to theonEndOfMediaPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onEndOfMediaProperty().bind(anotherProperty)) // Use shorthand form .onEndOfMediaPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onErrorPropertyApply
Applies a function to theonErrorPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onErrorProperty().bind(anotherProperty)) // Use shorthand form .onErrorPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onHaltedPropertyApply
Applies a function to theonHaltedPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onHaltedProperty().bind(anotherProperty)) // Use shorthand form .onHaltedPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onMarkerPropertyApply
public MediaPlayerBuilder onMarkerPropertyApply(Consumer<ObjectProperty<EventHandler<MediaMarkerEvent>>> op) Applies a function to theonMarkerPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onMarkerProperty().bind(anotherProperty)) // Use shorthand form .onMarkerPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onPausedPropertyApply
Applies a function to theonPausedPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onPausedProperty().bind(anotherProperty)) // Use shorthand form .onPausedPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onPlayingPropertyApply
Applies a function to theonPlayingPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onPlayingProperty().bind(anotherProperty)) // Use shorthand form .onPlayingPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onReadyPropertyApply
Applies a function to theonReadyPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onReadyProperty().bind(anotherProperty)) // Use shorthand form .onReadyPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onRepeatPropertyApply
Applies a function to theonRepeatPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onRepeatProperty().bind(anotherProperty)) // Use shorthand form .onRepeatPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onStalledPropertyApply
Applies a function to theonStalledPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onStalledProperty().bind(anotherProperty)) // Use shorthand form .onStalledPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
onStoppedPropertyApply
Applies a function to theonStoppedPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.onStoppedProperty().bind(anotherProperty)) // Use shorthand form .onStoppedPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
ratePropertyApply
Applies a function to theratePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.rateProperty().bind(anotherProperty)) // Use shorthand form .ratePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
startTimePropertyApply
Applies a function to thestartTimePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.startTimeProperty().bind(anotherProperty)) // Use shorthand form .startTimePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
statusPropertyApply
public MediaPlayerBuilder statusPropertyApply(Consumer<ReadOnlyObjectProperty<MediaPlayer.Status>> op) Applies a function to thestatusPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.statusProperty().bind(anotherProperty)) // Use shorthand form .statusPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
stopTimePropertyApply
Applies a function to thestopTimePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.stopTimeProperty().bind(anotherProperty)) // Use shorthand form .stopTimePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
totalDurationPropertyApply
Applies a function to thetotalDurationPropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.totalDurationProperty().bind(anotherProperty)) // Use shorthand form .totalDurationPropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-
volumePropertyApply
Applies a function to thevolumePropertyof the instance being constructed. This serves as a shorthand form of theapplymethod.Example:
// Use apply .apply(obj -> obj.volumeProperty().bind(anotherProperty)) // Use shorthand form .volumePropertyApply(prop -> prop.bind(anotherProperty))- Returns:
- builder instance
-