videojs / videojs-playlist

Playlist plugin for videojs
Other
366 stars 124 forks source link

refactor: Class-based rewrite #257

Closed alex-barstow closed 8 months ago

alex-barstow commented 9 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 on the Playlist playlist.shuffle();

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

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


- `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 set the currentIndex to `null`
- 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