blob: 8168e8f2d2506c3440bd9b123944db19bffc24ab (
plain) (
tree)
|
|
import videojs, { VideoJsPlayer } from 'video.js'
const Component = videojs.getComponent('Component')
class PeerTubeLoadProgressBar extends Component {
constructor (player: VideoJsPlayer, options?: videojs.ComponentOptions) {
super(player, options)
this.on(player, 'progress', this.update)
}
createEl () {
return super.createEl('div', {
className: 'vjs-load-progress',
innerHTML: `<span class="vjs-control-text"><span>${this.localize('Loaded')}</span>: 0%</span>`
})
}
dispose () {
super.dispose()
}
update () {
const torrent = this.player().webtorrent().getTorrent()
if (!torrent) return
// FIXME: typings
(this.el() as HTMLElement).style.width = (torrent.progress * 100) + '%'
}
}
Component.registerComponent('PeerTubeLoadProgressBar', PeerTubeLoadProgressBar)
|