Playlist plugin
0.5 KB gzipTurns the player into a playlist with next, previous, auto-advance and loop. The plugin exposes an API through player.plugin("playlist") and emits plugin:playlistchange.
This player has three items; when one ends the next starts. The playlist demo adds next and previous buttons.
Install
npm i @tomato-player/plugin-playlist
Usage
player.ts — tsimport { createPlayer } from '@tomato-player/core';import { minimal } from '@tomato-player/skin-minimal';import { playlist } from '@tomato-player/plugin-playlist';createPlayer('#player', {src: 'movie.mp4',skin: minimal(),plugins: [playlist({ items: [{ src: 'a.mp4', title: 'Intro' }, { src: 'b.m3u8', title: 'Part 2' }], loop: true })],});
Options
| Option | Type | Description |
|---|---|---|
| items | PlaylistItem[] | Items with src, title, poster and tracks. |
| start | number | Index to start from (default 0). |
| autoAdvance | boolean | Play the next item when one ends (default true). |
| loop | boolean | Go back to the first item after the last. |