1 import videojs from 'video.js'
2 import { PlaylistPluginOptions } from '../peertube-videojs-typings'
3 import { PlaylistMenu } from './playlist-menu'
5 const ClickableComponent = videojs.getComponent('ClickableComponent')
7 class PlaylistButton extends ClickableComponent {
8 private playlistInfoElement: HTMLElement
9 private wrapper: HTMLElement
11 constructor (player: videojs.Player, options?: PlaylistPluginOptions & { playlistMenu: PlaylistMenu }) {
12 super(player, options as any)
16 this.wrapper = super.createEl('div', {
17 className: 'vjs-playlist-button',
22 const icon = super.createEl('div', {
23 className: 'vjs-playlist-icon',
28 this.playlistInfoElement = super.createEl('div', {
29 className: 'vjs-playlist-info',
34 this.wrapper.appendChild(icon)
35 this.wrapper.appendChild(this.playlistInfoElement)
43 const options = this.options_ as PlaylistPluginOptions
45 this.playlistInfoElement.innerHTML = options.getCurrentPosition() + '/' + options.playlist.videosLength
46 this.wrapper.title = this.player().localize('Playlist: {1}', [ options.playlist.displayName ])
50 const playlistMenu = this.getPlaylistMenu()
54 private getPlaylistMenu () {
55 return (this.options_ as any).playlistMenu as PlaylistMenu
59 videojs.registerComponent('PlaylistButton', PlaylistButton)
61 export { PlaylistButton }