Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: Media

[12:7] extends: FxObj

Wraps JavaFX Media, which represents a media resource (audio or video) loaded from a URI for playback through a MediaPlayer. The source must be a fully qualified URI string using the file:// scheme for local files or http:// for network streams. Once constructed, pass this object to a MediaPlayer to control playback.

Methods

  • Media (string Source)

    Creates a new Media object from the given URI string.

    • @p Source is a string with the media URI, e.g., file:///path/to/file.mp4.
    • @r this object
  • getSource ()

    Returns the source URI string used to create this Media object.

    • @r A string with the source URI.
  • getWidth ()

    Returns the width in pixels of the video, or 0 for audio-only media.

    • @r An int with the video width.
  • getHeight ()

    Returns the height in pixels of the video, or 0 for audio-only media.

    • @r An int with the video height.
  • getDuration ()

    Returns the duration of the media in milliseconds.

    • @r A double with the duration in milliseconds.
  • getError ()

    Returns the most recent media error, or null when no error has been reported.

    • @r An AJO holding the javafx.scene.media.MediaException, or null.
  • errorProperty ()

    Returns the read-only property holding the most recent media error.

    • @r A ReadOnlyObjectProperty AJO holding the MediaException.
  • setOnError (callback Cb)

    Sets a callback that fires when an error occurs while loading or processing the media.

    • @p Cb is a callback invoked with no arguments.
    • @r this object
  • getOnError ()

    Returns the current onError handler.

    • @r An AJO holding the Runnable, or null when none is set.
  • onErrorProperty ()

    Returns the property holding the onError handler.

    • @r An ObjectProperty AJO holding the Runnable.
  • getMetadata ()

    Returns the live ObservableMap of metadata key/value pairs read from the media source.

    • @r An ObservableMap AJO from String to Object.
  • widthProperty ()

    Returns the read-only property holding the media width in pixels.

    • @r A ReadOnlyIntegerProperty AJO.
  • heightProperty ()

    Returns the read-only property holding the media height in pixels.

    • @r A ReadOnlyIntegerProperty AJO.
  • durationProperty ()

    Returns the read-only property holding the media duration.

    • @r A ReadOnlyObjectProperty AJO holding the Duration.
  • getTracks ()

    Returns the live ObservableList of tracks that compose this media resource.

    • @r An ObservableList AJO of Track elements.
  • getMarkers ()

    Returns the live ObservableMap of named markers defined on this media, keyed by name with Duration values.

    • @r An ObservableMap AJO from String to Duration.