gameforge - v0.1.12
    Preparing search index...

    Interface IMediaInstance

    Interface for single instance return by a Sound play call. This can either be a WebAudio or HTMLAudio instance.

    interface IMediaInstance {
        id: number;
        loop: boolean;
        muted: boolean;
        paused: boolean;
        progress: number;
        speed: number;
        volume: number;
        destroy(): void;
        init(parent: IMedia): void;
        off(
            event:
                | "progress"
                | "pause"
                | "stop"
                | "end"
                | "start"
                | "resumed"
                | "paused",
            fn?: (...args: any[]) => void,
            context?: any,
            once?: boolean,
        ): this;
        on(event: "pause", fn: (paused: boolean) => void, context?: any): this;
        on(
            event: "progress",
            fn: (progress: number, duration: number) => void,
            context?: any,
        ): this;
        on(
            event: "stop" | "end" | "start" | "resumed" | "paused",
            fn: () => void,
            context?: any,
        ): this;
        once(event: "pause", fn: (paused: boolean) => void, context?: any): this;
        once(
            event: "progress",
            fn: (progress: number, duration: number) => void,
            context?: any,
        ): this;
        once(
            event: "stop" | "end" | "start" | "resumed" | "paused",
            fn: () => void,
            context?: any,
        ): this;
        play(options: PlayOptions): void;
        refresh(): void;
        refreshPaused(): void;
        set(
            name: "paused" | "speed" | "volume" | "muted" | "loop",
            value: number | boolean,
        ): this;
        stop(): void;
        toString(): string;
    }

    Implemented by

    Index

    Properties

    id: number

    Auto-incrementing ID for the instance.

    loop: boolean

    If the current instance is set to loop

    muted: boolean

    Set the muted state of the instance

    paused: boolean

    If the instance is paused, if the sound or global context is paused, this could still be false.

    progress: number

    Current progress of the sound from 0 to 1

    speed: number

    Current speed of the instance. This is not the actual speed since it takes into account the global context and the sound volume.

    volume: number

    Current volume of the instance. This is not the actual volume since it takes into account the global context and the sound volume.

    Methods

    • Returns void

    • Parameters

      Returns void

    • Parameters

      • event: "progress" | "pause" | "stop" | "end" | "start" | "resumed" | "paused"
      • Optionalfn: (...args: any[]) => void
      • Optionalcontext: any
      • Optionalonce: boolean

      Returns this

    • Parameters

      • event: "pause"
      • fn: (paused: boolean) => void
      • Optionalcontext: any

      Returns this

    • Parameters

      • event: "progress"
      • fn: (progress: number, duration: number) => void
      • Optionalcontext: any

      Returns this

    • Parameters

      • event: "stop" | "end" | "start" | "resumed" | "paused"
      • fn: () => void
      • Optionalcontext: any

      Returns this

    • Parameters

      • event: "pause"
      • fn: (paused: boolean) => void
      • Optionalcontext: any

      Returns this

    • Parameters

      • event: "progress"
      • fn: (progress: number, duration: number) => void
      • Optionalcontext: any

      Returns this

    • Parameters

      • event: "stop" | "end" | "start" | "resumed" | "paused"
      • fn: () => void
      • Optionalcontext: any

      Returns this

    • Parameters

      Returns void

    • Returns void

    • Fired when the sound when progress updates.

      Parameters

      • name: "paused" | "speed" | "volume" | "muted" | "loop"

        Name of property.

      • value: number | boolean

        The total number of seconds of audio

      Returns this

      import { sound } from '@pixi/sound';
      sound.play('foo')
      .set('volume', 0.5)
      .set('speed', 0.8);
    • Stop the current instance from playing.

      Returns void

    • Returns string

    Events

    • Fired when instance is resumed. resumed

      Returns void