1 import videojs from 'video.js'
2 import { EndCardOptions } from './end-card'
4 const Plugin = videojs.getPlugin('plugin')
6 class UpNextPlugin extends Plugin {
8 constructor (player: videojs.Player, options: Partial<EndCardOptions> = {}) {
11 getTitle: options.getTitle,
12 timeout: options.timeout || 5000,
13 cancelText: options.cancelText || 'Cancel',
14 headText: options.headText || 'Up Next',
15 suspendedText: options.suspendedText || 'Autoplay is suspended',
16 condition: options.condition,
17 suspended: options.suspended
22 // UpNext plugin can be called later, so ensure the player is not disposed
23 if (this.player.isDisposed()) return
25 this.player.ready(() => {
26 player.addClass('vjs-upnext')
29 player.addChild('EndCard', settings)
33 videojs.registerPlugin('upnext', UpNextPlugin)
34 export { UpNextPlugin }