-import './videojs-components/settings-menu-button'
import videojs from 'video.js'
import { timeToInt } from '@shared/core-utils'
import {
saveVideoWatchHistory,
saveVolumeInStore
} from './peertube-player-local-storage'
-import { PeerTubePluginOptions, ResolutionUpdateData, UserWatching, VideoJSCaption } from './peertube-videojs-typings'
+import { PeerTubePluginOptions, UserWatching, VideoJSCaption } from './peertube-videojs-typings'
import { isMobile } from './utils'
const Plugin = videojs.getPlugin('plugin')
private videoViewInterval: any
private userWatchingVideoInterval: any
- private lastResolutionChange: ResolutionUpdateData
private isLive: boolean
this.player.ready(() => {
const playerOptions = this.player.options_
- if (options.mode === 'webtorrent') {
- this.player.webtorrent().on('resolutionChange', (_: any, d: any) => this.handleResolutionChange(d))
- this.player.webtorrent().on('autoResolutionChange', (_: any, d: any) => this.trigger('autoResolutionChange', d))
- }
-
- if (options.mode === 'p2p-media-loader') {
- this.player.p2pMediaLoader().on('resolutionChange', (_: any, d: any) => this.handleResolutionChange(d))
- }
-
- this.player.tech(true).on('loadedqualitydata', () => {
- setTimeout(() => {
- // Replay a resolution change, now we loaded all quality data
- if (this.lastResolutionChange) this.handleResolutionChange(this.lastResolutionChange)
- }, 0)
- })
-
const volume = getStoredVolume()
if (volume !== undefined) this.player.volume(volume)
})
}
- this.player.textTracks().on('change', () => {
+ this.player.textTracks().addEventListener('change', () => {
const showing = this.player.textTracks().tracks_.find(t => {
return t.kind === 'captions' && t.mode === 'showing'
})
const body = new URLSearchParams()
body.append('currentTime', currentTime.toString())
- const headers = new Headers({ 'Authorization': authorizationHeader })
+ const headers = new Headers({ Authorization: authorizationHeader })
return fetch(url, { method: 'PUT', body, headers })
}
- private handleResolutionChange (data: ResolutionUpdateData) {
- this.lastResolutionChange = data
-
- const qualityLevels = this.player.qualityLevels()
-
- for (let i = 0; i < qualityLevels.length; i++) {
- if (qualityLevels[i].height === data.resolutionId) {
- data.id = qualityLevels[i].id
- break
- }
- }
-
- this.trigger('resolutionChange', data)
- }
-
private listenControlBarMouse () {
this.player.controlBar.on('mouseenter', () => {
this.mouseInControlBar = true