Fix videojs
[oweals/peertube.git] / client / src / assets / player / upnext / upnext-plugin.ts
1 import videojs from 'video.js'
2 import { EndCardOptions } from './end-card'
3
4 const Plugin = videojs.getPlugin('plugin')
5
6 class UpNextPlugin extends Plugin {
7
8   constructor (player: videojs.Player, options: Partial<EndCardOptions> = {}) {
9     const settings = {
10       next: options.next,
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
18     }
19
20     super(player)
21
22     this.player.ready(() => {
23       player.addClass('vjs-upnext')
24     })
25
26     player.addChild('EndCard', settings)
27   }
28 }
29
30 videojs.registerPlugin('upnext', UpNextPlugin)
31 export { UpNextPlugin }