import videojs, { VideoJsPlayer } from 'video.js' function getPauseBezel () { return `
` } function getPlayBezel () { return `
` } const Component = videojs.getComponent('Component') class PauseBezel extends Component { container: HTMLDivElement constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) { super(player, options) player.on('pause', (_: any) => { if (player.seeking() || player.ended()) return this.container.innerHTML = getPauseBezel() this.showBezel() }) player.on('play', (_: any) => { if (player.seeking()) return this.container.innerHTML = getPlayBezel() this.showBezel() }) } createEl () { this.container = super.createEl('div', { className: 'vjs-bezels-content' }) as HTMLDivElement this.container.style.display = 'none' return this.container } showBezel () { this.container.style.display = 'inherit' setTimeout(() => { this.container.style.display = 'none' }, 500) // matching the animation duration } } videojs.registerComponent('PauseBezel', PauseBezel)