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 async function loadVideoInfo (videoId: string): Promise<VideoDetails> {
10 const response = await fetch(window.location.origin + '/api/v1/videos/' + videoId)
11 return response.json()
14 const urlParts = window.location.href.split('/')
15 const videoId = urlParts[urlParts.length - 1]
17 loadVideoInfo(videoId)
19 const videoElement = document.getElementById('video-container') as HTMLVideoElement
20 const previewUrl = window.location.origin + videoInfo.previewPath
21 videoElement.poster = previewUrl
23 const videojsOptions = {
28 videoFiles: videoInfo.files,
29 playerElement: videoElement,
33 enableVolumeScroll: false
37 videojs('video-container', videojsOptions, function () {
45 .catch(err => console.error(err))