next-video-button.ts 917 B

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