videojs / videojs-playlist

Playlist plugin for videojs
Other
366 stars 124 forks source link

refactor: Class-based rewrite #256

Closed alex-barstow closed 9 months ago

alex-barstow commented 10 months ago

Description

This is a complete rewrite using a class-based "advanced plugin" structure. This will require a new major version.

Notable changes from old plugin (not an exhaustive list)

// Perform sorting operations playlistPlugin.shuffle();

// Load first item after the playlist has been sorted playlistPlugin.loadFirst();

// Alternatively, they can use playlistchange, which happens after setting the playlist and before any item is set player.on('playlistchange', () => { playlistPlugin.shuffle(); playlistPlugin.loadFirst(); })


- `playlistchange` is now fired synchronously immediately after the playlist is updated. It is up to integrators to avoid running heavy tasks in `playlistchange` handlers.
- Methods no longer throw errors.
- Executed `@todo` changes and removed deprecated functionality
  - removed `playlistchange` event [`action`](https://github.com/videojs/videojs-playlist/blob/beba231253c9f283cd077c70770fc49384554cb9/docs/api.md#action) property. `add()` and `remove()` methods now only trigger `playlist` and `playlist` remove, not `playlistchange`
  - `playlistchange` event fires [every time](https://github.com/videojs/videojs-playlist/blob/beba231253c9f283cd077c70770fc49384554cb9/docs/api.md#backward-compatibility) a playlist is set, even the first time
- If a `remove()` call removes the current item, we now automatically load the next available `PlaylistItem`, or call `player.reset()` if none are available
- Replaced the [old poster flash solution](https://github.com/videojs/videojs-playlist/blob/beba231253c9f283cd077c70770fc49384554cb9/src/playlist-maker.js#L316-L324) with a non-index-based poster flash solution that will also handle cases when we repeat after the last item
- Various bug fixes
- Added more validation
- More robust tests
- Expanded the `index.html` demo page