Interface PlayerElement

A Ruffle player's HTML element.

This is either created through window.RufflePlayer.latest().createPlayer(), or polyfilled from a <embed>/<object> tag.

In addition to usual HTML attributes, this player contains methods and properties that belong to both the Flash JS API and legacy Ruffle APIs.

interface PlayerElement {
    onFSCommand: null | ((command: string, args: string) => boolean);
    config: object | URLLoadOptions | DataLoadOptions;
    loadedConfig: null | URLLoadOptions | DataLoadOptions;
    get readyState(): ReadyState;
    get metadata(): null | MovieMetadata;
    reload(): Promise<void>;
    load(options: string | URLLoadOptions | DataLoadOptions): Promise<void>;
    play(): void;
    get isPlaying(): boolean;
    volume: number;
    get fullscreenEnabled(): boolean;
    get isFullscreen(): boolean;
    setFullscreen(isFull: boolean): void;
    enterFullscreen(): void;
    exitFullscreen(): void;
    pause(): void;
    set traceObserver(observer: null | ((message: string) => void));
    downloadSwf(): Promise<void>;
    displayMessage(message: string): void;
    PercentLoaded(): number;
}

Hierarchy (view full)

Properties

onFSCommand: null | ((command: string, args: string) => boolean)

A movie can communicate with the hosting page using fscommand as long as script access is allowed.

A string passed to the host application for any use.

A string passed to the host application for any use.

True if the command was handled.

config: object | URLLoadOptions | DataLoadOptions

Any configuration that should apply to this specific player. This will be defaulted with any global configuration.

loadedConfig: null | URLLoadOptions | DataLoadOptions

The effective config loaded with the last call to load(). If no such call has been made, this will be null.

Accessors

  • get readyState(): ReadyState
  • Indicates the readiness of the playing movie.

    Returns ReadyState

    The ReadyState of the player.

  • get metadata(): null | MovieMetadata
  • The metadata of the playing movie (such as movie width and height). These are inherent properties stored in the SWF file and are not affected by runtime changes. For example, metadata.width is the width of the SWF file, and not the width of the Ruffle player.

    Returns null | MovieMetadata

    The metadata of the movie, or null if the movie metadata has not yet loaded.

  • get isPlaying(): boolean
  • Whether this player is currently playing.

    Returns boolean

    True if this player is playing, false if it's paused or hasn't started yet.

  • get volume(): number
  • Returns the master volume of the player.

    The volume is linear and not adapted for logarithmic hearing.

    Returns number

    The volume. 1.0 is 100% volume.

  • set volume(value): void
  • Sets the master volume of the player.

    The volume should be linear and not adapted for logarithmic hearing.

    Parameters

    • value: number

      The volume. 1.0 is 100% volume.

    Returns void

  • get fullscreenEnabled(): boolean
  • Checks if this player is allowed to be fullscreen by the browser.

    Returns boolean

    True if you may call enterFullscreen.

  • get isFullscreen(): boolean
  • Checks if this player is currently fullscreen inside the browser.

    Returns boolean

    True if it is fullscreen.

  • set traceObserver(observer): void
  • Sets a trace observer on this flash player.

    The observer will be called, as a function, for each message that the playing movie will "trace" (output).

    Parameters

    • observer: null | ((message: string) => void)

      The observer that will be called for each trace.

    Returns void

Methods

  • Loads a specified movie into this player.

    This will replace any existing movie that may be playing.

    Parameters

    • options: string | URLLoadOptions | DataLoadOptions

      One of the following:

      • A URL, passed as a string, which will load a URL with default options.
      • A URLLoadOptions object, to load a URL with options.
      • A DataLoadOptions object, to load data with options. The options, if provided, must only contain values provided for this specific movie. They must not contain any default values, since those would overwrite other configuration settings with a lower priority (e.g. the general RufflePlayer config).

      The options will be defaulted by the config field, which itself is defaulted by a global window.RufflePlayer.config.

    Returns Promise<void>

  • Exported function that requests the browser to change the fullscreen state if it is allowed.

    Parameters

    • isFull: boolean

      Whether to set to fullscreen or return to normal.

    Returns void

  • Pauses this player.

    No more frames, scripts or sounds will be executed. This movie will be considered inactive and will not wake up until resumed.

    Returns void

  • Returns the movies loaded process, in a percent from 0 to 100. Ruffle may just return 0 or 100.

    Returns number

    a value from 0 to 100, inclusive.