aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/videojs-components/next-video-button.ts
blob: 22b32f06b93516993d6f4feb7e19f80723af68b2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import videojs from 'video.js'

const Button = videojs.getComponent('Button')

export interface NextVideoButtonOptions extends videojs.ComponentOptions {
  handler: Function
}

class NextVideoButton extends Button {
  private readonly nextVideoButtonOptions: NextVideoButtonOptions

  constructor (player: videojs.Player, options?: NextVideoButtonOptions) {
    super(player, options)

    this.nextVideoButtonOptions = options
  }

  createEl () {
    const button = videojs.dom.createEl('button', {
      className: 'vjs-next-video'
    }) as HTMLButtonElement
    const nextIcon = videojs.dom.createEl('span', {
      className: 'icon icon-next'
    })
    button.appendChild(nextIcon)

    button.title = this.player_.localize('Next video')

    return button
  }

  handleClick () {
    this.nextVideoButtonOptions.handler()
  }
}

videojs.registerComponent('NextVideoButton', NextVideoButton)