Interface Event

The Event module allows listening to mpv and IINA events. Event names should be prefixed with either iina. or mpv. to specify the source. This module mainly provides two methods, on and off. The on method is used to register a callback function to an event, which will return a unique string ID for the callback. This ID can be used to remove the callback using the off method.

The callback function may be called with associated data, such as the new file path for the iina.file-loaded event. However, most events do not provide any data, and the callback function should get necessary information from the mpv or the core module.

All mpv events can be used here by simply adding mpv. before the event name, e.g. mpv.end-file. Please refer to mpv's documentation for a list of mpv events. When listenting to mpv property changes, add the .changed suffix to the property name, e.g. mpv.volume.changed.

The IINA events are listed below.

Example

// show the file's path when playing a new file
const eventID = event.on("iina.file-loaded", () => {
core.osd(`Playing ${core.status.url}`);
})

// remove the listener
event.off("iina.file-loaded", eventID);

// using the mpv API: show the current volume when it changes
event.on("mpv.volume.changed", () => {
core.osd(`Volume: ${mpv.getNumber("volume")}`);
});

Seealso

mpv's list of events.

Available In Entry

Main entry only

Hierarchy

  • Event

Methods

Methods

  • Get notified when the player's window is loaded. The window must be loaded before you can display OSDs and overlays.

    Parameters

    • event: "iina.window-loaded"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the width and/or height of the video has changed, and the player window has been resized accordingly. Typically, this is due to a new file being played, a crop filter is applied, or a video track change. You may respond to video aspect ratio changes here.

    Parameters

    • event: "iina.window-size-adjusted"
    • callback: ((frame: Rect) => void)
        • (frame: Rect): void
        • Parameters

          • frame: Rect

            The new frame of the player window.

          Returns void

    Returns string

  • Get notified when the player window is moved, either by the user or by IINA.

    Parameters

    • event: "iina.window-moved"
    • callback: ((frame: Rect) => void)
        • (frame: Rect): void
        • Parameters

          • frame: Rect

            The new frame of the player window.

          Returns void

    Returns string

  • Get notified when the player window is resized, either by the user or by IINA.

    Parameters

    • event: "iina.window-resized"
    • callback: ((frame: Rect) => void)
        • (frame: Rect): void
        • Parameters

          • frame: Rect

            The new frame of the player window.

          Returns void

    Returns string

  • Get notified when the player window's fullscreen status has changed.

    Parameters

    • event: "iina.window-fs.changed"
    • callback: ((status: boolean) => void)
        • (status: boolean): void
        • Parameters

          • status: boolean

            The new fullscreen status.

          Returns void

    Returns string

  • Get notified when the player window is moved to another screen.

    Parameters

    • event: "iina.window-screen.changed"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the player window is minimized.

    Parameters

    • event: "iina.window-miniaturized"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the player window is deminiaturized.

    Parameters

    • event: "iina.window-deminiaturized"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the player window becomes or stops being the main window. This essentially means that the player window is or is not the frontmost window that accepts keyboard and mouse input.

    Parameters

    • event: "iina.window-main.changed"
    • callback: ((status: boolean) => void)
        • (status: boolean): void
        • Parameters

          • status: boolean

            Whether the window is the main window.

          Returns void

    Returns string

  • Get notified when the player window is about to close.

    Parameters

    • event: "iina.window-will-close"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the player window is closed.

    Parameters

    • event: "iina.window-did-close"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the player enters or exits music mode (mini player).

    Parameters

    • event: "iina.music-mode.changed"
    • callback: ((status: boolean) => void)
        • (status: boolean): void
        • Parameters

          • status: boolean

            Whether the player is in music mode.

          Returns void

    Returns string

  • Get notified when the player enters or exits Picture-in-Picture (PIP) mode.

    Parameters

    • event: "iina.pip.changed"
    • callback: ((status: boolean) => void)
        • (status: boolean): void
        • Parameters

          • status: boolean

            The new PIP status.

          Returns void

    Returns string

  • Get notified when a new file is loaded.

    Parameters

    • event: "iina.file-loaded"
    • callback: ((url: string) => void)
        • (url: string): void
        • Parameters

          • url: string

            The new file's URL.

          Returns void

    Returns string

  • Get notified when a new file has started playing.

    Parameters

    • event: "iina.file-started"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the mpv instance is initialized.

    Parameters

    • event: "iina.mpv-inititalized"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the thumbnails of the current video are generated.

    Parameters

    • event: "iina.thumbnails-ready"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Get notified when the video overlay view for this plugin is loaded.

    Seealso

    The overlay module.

    Parameters

    • event: "iina.plugin-overlay-loaded"
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Add listener to an mpv event.

    Parameters

    • event: `mpv.${string}`
    • callback: (() => void)
        • (): void
        • Returns void

    Returns string

  • Remove a listener from an event.

    Parameters

    • event: string

      The event name.

    • id: string

      The unique string ID returned by the on method.

    Returns any

Generated using TypeDoc