]>
Commit | Line | Data |
---|---|---|
1 | import videojs, { VideoJsPlayer } from 'video.js' | |
2 | ||
3 | const Button = videojs.getComponent('Button') | |
4 | ||
5 | export interface NextVideoButtonOptions extends videojs.ComponentOptions { | |
6 | handler: Function | |
7 | } | |
8 | ||
9 | class NextVideoButton extends Button { | |
10 | private readonly nextVideoButtonOptions: NextVideoButtonOptions | |
11 | ||
12 | constructor (player: VideoJsPlayer, options?: NextVideoButtonOptions) { | |
13 | super(player, options) | |
14 | ||
15 | this.nextVideoButtonOptions = options | |
16 | } | |
17 | ||
18 | createEl () { | |
19 | const button = videojs.dom.createEl('button', { | |
20 | className: 'vjs-next-video' | |
21 | }) as HTMLButtonElement | |
22 | const nextIcon = videojs.dom.createEl('span', { | |
23 | className: 'icon icon-next' | |
24 | }) | |
25 | button.appendChild(nextIcon) | |
26 | ||
27 | button.title = this.player_.localize('Next video') | |
28 | ||
29 | return button | |
30 | } | |
31 | ||
32 | handleClick () { | |
33 | this.nextVideoButtonOptions.handler() | |
34 | } | |
35 | } | |
36 | ||
37 | videojs.registerComponent('NextVideoButton', NextVideoButton) |