java.lang.Object
io.github.sosuisen.jfxbuilder.media.MediaPlayerBuilder

public class MediaPlayerBuilder extends Object
The 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 Details

    • create

      public static MediaPlayerBuilder create(Media media)
      Accepts the constructor arguments of MediaPlayer(Media) and returns an instance of MediaPlayerBuilder.
      Returns:
      an instance of the MediaPlayerBuilder.
    • build

      public MediaPlayer build()
      Builds and returns an instance of the MediaPlayer class.

      Intermediate builder methods are not evaluated until the build method is called; in other words, they are evaluated lazily.

      Returns:
      new instance of the MediaPlayer class
    • apply

      public MediaPlayerBuilder apply(Consumer<MediaPlayer> func)
      Applies a function to the MediaPlayer instance being constructed. Most operations on the instance can be performed using this method.
      Returns:
      builder instance
    • audioSpectrumInterval

      public MediaPlayerBuilder audioSpectrumInterval(double value)
      A builder method that invokes the setAudioSpectrumInterval method on the instance being constructed.
      Returns:
      builder instance
    • audioSpectrumListener

      public MediaPlayerBuilder audioSpectrumListener(AudioSpectrumListener listener)
      A builder method that invokes the setAudioSpectrumListener method on the instance being constructed.
      Returns:
      builder instance
    • audioSpectrumNumBands

      public MediaPlayerBuilder audioSpectrumNumBands(int value)
      A builder method that invokes the setAudioSpectrumNumBands method on the instance being constructed.
      Returns:
      builder instance
    • audioSpectrumThreshold

      public MediaPlayerBuilder audioSpectrumThreshold(int value)
      A builder method that invokes the setAudioSpectrumThreshold method on the instance being constructed.
      Returns:
      builder instance
    • autoPlay

      public MediaPlayerBuilder autoPlay(boolean value)
      A builder method that invokes the setAutoPlay method on the instance being constructed.
      Returns:
      builder instance
    • balance

      public MediaPlayerBuilder balance(double value)
      A builder method that invokes the setBalance method on the instance being constructed.
      Returns:
      builder instance
    • cycleCount

      public MediaPlayerBuilder cycleCount(int value)
      A builder method that invokes the setCycleCount method on the instance being constructed.
      Returns:
      builder instance
    • mute

      public MediaPlayerBuilder mute(boolean value)
      A builder method that invokes the setMute method on the instance being constructed.
      Returns:
      builder instance
    • onEndOfMedia

      public MediaPlayerBuilder onEndOfMedia(Runnable value)
      A builder method that invokes the setOnEndOfMedia method on the instance being constructed.
      Returns:
      builder instance
    • onError

      public MediaPlayerBuilder onError(Runnable value)
      A builder method that invokes the setOnError method on the instance being constructed.
      Returns:
      builder instance
    • onHalted

      public MediaPlayerBuilder onHalted(Runnable value)
      A builder method that invokes the setOnHalted method on the instance being constructed.
      Returns:
      builder instance
    • onMarker

      public MediaPlayerBuilder onMarker(EventHandler<MediaMarkerEvent> onMarker)
      A builder method that invokes the setOnMarker method on the instance being constructed.
      Returns:
      builder instance
    • onPaused

      public MediaPlayerBuilder onPaused(Runnable value)
      A builder method that invokes the setOnPaused method on the instance being constructed.
      Returns:
      builder instance
    • onPlaying

      public MediaPlayerBuilder onPlaying(Runnable value)
      A builder method that invokes the setOnPlaying method on the instance being constructed.
      Returns:
      builder instance
    • onReady

      public MediaPlayerBuilder onReady(Runnable value)
      A builder method that invokes the setOnReady method on the instance being constructed.
      Returns:
      builder instance
    • onRepeat

      public MediaPlayerBuilder onRepeat(Runnable value)
      A builder method that invokes the setOnRepeat method on the instance being constructed.
      Returns:
      builder instance
    • onStalled

      public MediaPlayerBuilder onStalled(Runnable value)
      A builder method that invokes the setOnStalled method on the instance being constructed.
      Returns:
      builder instance
    • onStopped

      public MediaPlayerBuilder onStopped(Runnable value)
      A builder method that invokes the setOnStopped method on the instance being constructed.
      Returns:
      builder instance
    • rate

      public MediaPlayerBuilder rate(double value)
      A builder method that invokes the setRate method on the instance being constructed.
      Returns:
      builder instance
    • startTime

      public MediaPlayerBuilder startTime(Duration value)
      A builder method that invokes the setStartTime method on the instance being constructed.
      Returns:
      builder instance
    • stopTime

      public MediaPlayerBuilder stopTime(Duration value)
      A builder method that invokes the setStopTime method on the instance being constructed.
      Returns:
      builder instance
    • volume

      public MediaPlayerBuilder volume(double value)
      A builder method that invokes the setVolume method on the instance being constructed.
      Returns:
      builder instance
    • audioSpectrumIntervalPropertyApply

      public MediaPlayerBuilder audioSpectrumIntervalPropertyApply(Consumer<DoubleProperty> op)
      Applies a function to the audioSpectrumIntervalProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      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 the audioSpectrumListenerProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.audioSpectrumListenerProperty().bind(anotherProperty))
      
      // Use shorthand form
      .audioSpectrumListenerPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • audioSpectrumNumBandsPropertyApply

      public MediaPlayerBuilder audioSpectrumNumBandsPropertyApply(Consumer<IntegerProperty> op)
      Applies a function to the audioSpectrumNumBandsProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.audioSpectrumNumBandsProperty().bind(anotherProperty))
      
      // Use shorthand form
      .audioSpectrumNumBandsPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • audioSpectrumThresholdPropertyApply

      public MediaPlayerBuilder audioSpectrumThresholdPropertyApply(Consumer<IntegerProperty> op)
      Applies a function to the audioSpectrumThresholdProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.audioSpectrumThresholdProperty().bind(anotherProperty))
      
      // Use shorthand form
      .audioSpectrumThresholdPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • autoPlayPropertyApply

      public MediaPlayerBuilder autoPlayPropertyApply(Consumer<BooleanProperty> op)
      Applies a function to the autoPlayProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.autoPlayProperty().bind(anotherProperty))
      
      // Use shorthand form
      .autoPlayPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • balancePropertyApply

      public MediaPlayerBuilder balancePropertyApply(Consumer<DoubleProperty> op)
      Applies a function to the balanceProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      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 the bufferProgressTimeProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.bufferProgressTimeProperty().bind(anotherProperty))
      
      // Use shorthand form
      .bufferProgressTimePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • currentCountPropertyApply

      public MediaPlayerBuilder currentCountPropertyApply(Consumer<ReadOnlyIntegerProperty> op)
      Applies a function to the currentCountProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.currentCountProperty().bind(anotherProperty))
      
      // Use shorthand form
      .currentCountPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • currentRatePropertyApply

      public MediaPlayerBuilder currentRatePropertyApply(Consumer<ReadOnlyDoubleProperty> op)
      Applies a function to the currentRateProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.currentRateProperty().bind(anotherProperty))
      
      // Use shorthand form
      .currentRatePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • currentTimePropertyApply

      public MediaPlayerBuilder currentTimePropertyApply(Consumer<ReadOnlyObjectProperty<Duration>> op)
      Applies a function to the currentTimeProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.currentTimeProperty().bind(anotherProperty))
      
      // Use shorthand form
      .currentTimePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • cycleCountPropertyApply

      public MediaPlayerBuilder cycleCountPropertyApply(Consumer<IntegerProperty> op)
      Applies a function to the cycleCountProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.cycleCountProperty().bind(anotherProperty))
      
      // Use shorthand form
      .cycleCountPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • cycleDurationPropertyApply

      public MediaPlayerBuilder cycleDurationPropertyApply(Consumer<ReadOnlyObjectProperty<Duration>> op)
      Applies a function to the cycleDurationProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      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 the errorProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.errorProperty().bind(anotherProperty))
      
      // Use shorthand form
      .errorPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • mutePropertyApply

      public MediaPlayerBuilder mutePropertyApply(Consumer<BooleanProperty> op)
      Applies a function to the muteProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.muteProperty().bind(anotherProperty))
      
      // Use shorthand form
      .mutePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onEndOfMediaPropertyApply

      public MediaPlayerBuilder onEndOfMediaPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onEndOfMediaProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onEndOfMediaProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onEndOfMediaPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onErrorPropertyApply

      public MediaPlayerBuilder onErrorPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onErrorProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onErrorProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onErrorPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onHaltedPropertyApply

      public MediaPlayerBuilder onHaltedPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onHaltedProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onHaltedProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onHaltedPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onMarkerPropertyApply

      Applies a function to the onMarkerProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onMarkerProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onMarkerPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onPausedPropertyApply

      public MediaPlayerBuilder onPausedPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onPausedProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onPausedProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onPausedPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onPlayingPropertyApply

      public MediaPlayerBuilder onPlayingPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onPlayingProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onPlayingProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onPlayingPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onReadyPropertyApply

      public MediaPlayerBuilder onReadyPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onReadyProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onReadyProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onReadyPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onRepeatPropertyApply

      public MediaPlayerBuilder onRepeatPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onRepeatProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onRepeatProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onRepeatPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onStalledPropertyApply

      public MediaPlayerBuilder onStalledPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onStalledProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onStalledProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onStalledPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onStoppedPropertyApply

      public MediaPlayerBuilder onStoppedPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onStoppedProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onStoppedProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onStoppedPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • ratePropertyApply

      public MediaPlayerBuilder ratePropertyApply(Consumer<DoubleProperty> op)
      Applies a function to the rateProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.rateProperty().bind(anotherProperty))
      
      // Use shorthand form
      .ratePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • startTimePropertyApply

      public MediaPlayerBuilder startTimePropertyApply(Consumer<ObjectProperty<Duration>> op)
      Applies a function to the startTimeProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.startTimeProperty().bind(anotherProperty))
      
      // Use shorthand form
      .startTimePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • statusPropertyApply

      Applies a function to the statusProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.statusProperty().bind(anotherProperty))
      
      // Use shorthand form
      .statusPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • stopTimePropertyApply

      public MediaPlayerBuilder stopTimePropertyApply(Consumer<ObjectProperty<Duration>> op)
      Applies a function to the stopTimeProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.stopTimeProperty().bind(anotherProperty))
      
      // Use shorthand form
      .stopTimePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • totalDurationPropertyApply

      public MediaPlayerBuilder totalDurationPropertyApply(Consumer<ReadOnlyObjectProperty<Duration>> op)
      Applies a function to the totalDurationProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.totalDurationProperty().bind(anotherProperty))
      
      // Use shorthand form
      .totalDurationPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • volumePropertyApply

      public MediaPlayerBuilder volumePropertyApply(Consumer<DoubleProperty> op)
      Applies a function to the volumeProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.volumeProperty().bind(anotherProperty))
      
      // Use shorthand form
      .volumePropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance