aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/stats/stats-plugin.ts
blob: 3402e7861fa48819e714544c9e8f571dcb9b1c4a (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
import videojs from 'video.js'
import { StatsCard, StatsCardOptions } from './stats-card'

const Plugin = videojs.getPlugin('plugin')

class StatsForNerdsPlugin extends Plugin {
  private statsCard: StatsCard

  constructor (player: videojs.Player, options: Partial<StatsCardOptions> = {}) {
    const settings = {
      ...options
    }

    super(player)

    this.player.ready(() => {
      player.addClass('vjs-stats-for-nerds')
    })

    this.statsCard = new StatsCard(player, options)

    player.addChild(this.statsCard, settings)
  }

  show (options?: StatsCardOptions) {
    this.statsCard.show(options)
  }
}

videojs.registerPlugin('stats', StatsForNerdsPlugin)
export { StatsForNerdsPlugin }