Interface PlayerV1

interface PlayerV1 {
    addFSCommandHandler(
        handler: (command: string, args: string) => void,
    ): void;
    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>;
    get volume(): number;
    set volume(value: number): void;
    get fullscreenEnabled(): boolean;
    get isFullscreen(): boolean;
    requestFullscreen(): void;
    exitFullscreen(): void;
    get suspended(): boolean;
    suspend(): void;
    resume(): void;
    set traceObserver(observer: null | (message: string) => void): void;
    downloadSwf(): Promise<void>;
    displayMessage(message: string): void;
    callExternalInterface(name: string, ...args: unknown[]): unknown;
}

Properties

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 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 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: number): 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 isFullscreen(): boolean
  • Checks if this player is currently fullscreen inside the browser.

    Returns boolean

    True if it is fullscreen.

  • get suspended(): boolean
  • Checks if this movie is suspended.

    A suspended movie will not execute any frames, scripts or sounds. This movie is considered inactive and will not wake up until resumed. If no movie is loaded, this method will return true.

    Returns boolean

    true if the movie is suspended or does not exist, false if the movie is playing

    • suspend to suspend the player
    • resume to resume the player from suspension
  • set traceObserver(observer: null | (message: string) => void): 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

  • Adds a handler for arbitrary "fs commands" from a movie in this player.

    Parameters

    • handler: (command: string, args: string) => void

      A command handler to receive fscommands.

        • (command: string, args: string): void
        • Parameters

          • command: string

            An arbitrary name of a command.

          • args: string

            An arbitrary argument to the command.

          Returns void

    Returns void

    If script access is allowed, a movie may communicate to the page through the ActionScript method fscommand(name, args).

    The exact commands and their arguments are more or less arbitrary and up to the movie. This is an incredibly deprecated way of communicating between Flash and JavaScript, and was deprecated in favor of ExternalInterface in Flash Player 8 (2005).

  • Reloads the player, as if you called load with the same config as the last time it was called.

    If this player has never been loaded, this method will return an error.

    Returns Promise<void>

  • 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>

  • Requests the browser to no longer make this player fullscreen.

    Returns void

  • Suspends the movie.

    A suspended movie will not execute any frames, scripts or sounds. This movie is considered inactive and will not wake up until resumed. If the movie is already suspended or no movie is loaded, this method will do nothing.

    Returns void

    • suspended to check if the player is suspended
    • resume to resume the player from suspension
  • Resumes the movie from suspension.

    The movie will now resume executing any frames, scripts and sounds. If the movie is not suspended or no movie is loaded, this method will do nothing.

    Returns void

  • Show a dismissible message in front of the player.

    Parameters

    • message: string

      The message shown to the user.

    Returns void

  • Calls an External Interface callback with the given name and arguments.

    This will call any ActionScript code assigned to the given name. If no such External Interface callback exists with the given name, this method silently fails and returns undefined.

    Parameters

    • name: string

      Name of the callback to call.

    • ...args: unknown[]

      Any arguments to pass to the callback.

    Returns unknown

    Any value returned by the callback.