3 import * as videojs from 'video.js'
4 import 'videojs-hotkeys'
5 import '../../assets/player/peertube-videojs-plugin'
6 import 'videojs-dock/dist/videojs-dock.es.js'
7 import { VideoDetails } from '../../../../shared'
9 function loadVideoInfo (videoId: string, callback: (err: Error, res?: VideoDetails) => void) {
10 const xhttp = new XMLHttpRequest()
11 xhttp.onreadystatechange = function () {
12 if (this.readyState === 4 && this.status === 200) {
13 const json = JSON.parse(this.responseText)
14 return callback(null, json)
18 xhttp.onerror = err => callback(err.error)
20 const url = window.location.origin + '/api/v1/videos/' + videoId
21 xhttp.open('GET', url, true)
25 const urlParts = window.location.href.split('/')
26 const videoId = urlParts[urlParts.length - 1]
28 loadVideoInfo(videoId, (err, videoInfo) => {
34 const videoElement = document.getElementById('video-container') as HTMLVideoElement
35 const previewUrl = window.location.origin + videoInfo.previewPath
36 videoElement.poster = previewUrl
38 const videojsOptions = {
43 videoFiles: videoInfo.files,
44 playerElement: videoElement,
48 enableVolumeScroll: false
52 videojs('video-container', videojsOptions, function () {