Interface Playlist

The Playlist module provides methods to manipulate the playlist and add custom menu items to the playlist context menu.

Available In Entry

Main entry only

Hierarchy

  • Playlist

Methods

  • Get the number of items in the playlist.

    Returns number

  • Add an item to the playlist.

    Example

    playlist.add("https://example.com/video.mp4", 0 /* insert at the beginning * );
    

    Parameters

    • url: string

      The URL of the item.

    • Optional at: number

      The index to insert the item. If not specified, the item will be appended to the end of the playlist.

    Returns PlaylistItem

  • Move an item in the playlist.

    Parameters

    • index: number

      The index of the item to move.

    • to: number

      The destination index.

    Returns PlaylistItem

  • Play an item in the playlist.

    Parameters

    • index: number

      The index of the item to play.

    Returns void

  • Play the next item in the playlist.

    Returns void

  • Play the previous item in the playlist.

    Returns void

  • Provide a menu builder function to add custom menu items to the playlist context menu. When the user selects one or more items in the playlist and right-clicks on them, the menu builder function will be called with the selected items as an argument. It should return an array of menu items, which will be inserted into the context menu.

    Example

    // trash the selected items
    playlist.registerMenuBuilder(entries => [
    menu.item(`Trash these ${entries.length} files`, () => {
    for (const entry of entries) {
    file.trash(entry.filename);
    }
    }),
    ]);

    Parameters

    Returns void

Generated using TypeDoc