Interface Global

The Global module provides a way to create new player instances and communicate with them. The controlled player instances can have special properties, such as hidden User Interface, disabled window animations, disabled plugins, and more.

It also enables communication between the main entries and the global entry.

Available In Entry

Global and main. However, the createPlayerInstance method is only available in the global entry. Note that if the plugin doesn't have a global entry, the whole module will be unavailable.

Hierarchy

  • Global

Methods

  • Create a new controlled player instance. Available in the global entry only.

    Returns

    The ID of the new player instance.

    Parameters

    • options: Partial<{
          disableWindowAnimation: boolean;
          disableUI: boolean;
          enablePlugins: boolean;
          label: string;
          url: string;
      }>

      The options for the new player instance.

      • disableWindowAnimation: Disable window animations when opening/closing the window.
      • disableUI: Hide the window's User Interface.
      • enablePlugins: Enable all plugins for the new player instance.
      • label: A custom label of the new player instance. Can be obtained by global.getLabel() in the main entry. Note that if this option is set to false, the player will only have the current plugin loaded to ensure communication between the players and the global entry.
      • url: The URL to open in the new player instance.

    Returns number

  • Get the custom label of the current player instance. The label can be set by the label option of createPlayerInstance. Available in the main entry only.

    Returns string

  • Post a message to the (main entry of) player instance(s). Available in the global entry only.

    Parameters

    • target: string | number

      Specify the target player instance(s). If set to a string, it will be treated as the player instance's label. If set to a number, it will be treated as the player instance's ID. The ID is only available for plugin-created players returned by createPlayerInstance. If set to null, the message will be sent to all player instances.

    • name: string

      The message name.

    • data: any

      The message data.

    Returns void

  • Post message to the global entry. Available in the main entry only.

    Parameters

    • name: string

      The message name.

    • data: any

      The message data.

    Returns void

  • Register a message listener.

    Parameters

    • name: string

      The message name.

    • callback: ((data: any, player?: string) => void)

      The callback function.

        • (data: any, player?: string): void
        • Parameters

          • data: any

            The message data.

          • Optional player: string

            The player's ID. Available in the global entry only, and only when the message is sent from a player instance.

          Returns void

    Returns void

Generated using TypeDoc