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 getVideoUrl (id: string) {
10 return window.location.origin + '/api/v1/videos/' + id
13 async function loadVideoInfo (videoId: string): Promise<VideoDetails> {
14 const response = await fetch(getVideoUrl(videoId))
15 return response.json()
18 const urlParts = window.location.href.split('/')
19 const videoId = urlParts[urlParts.length - 1]
21 loadVideoInfo(videoId)
23 const videoElement = document.getElementById('video-container') as HTMLVideoElement
24 const previewUrl = window.location.origin + videoInfo.previewPath
25 videoElement.poster = previewUrl
27 const videojsOptions = {
32 videoFiles: videoInfo.files,
33 playerElement: videoElement,
35 videoViewUrl: getVideoUrl(videoId) + '/views',
36 videoDuration: videoInfo.duration
39 enableVolumeScroll: false
43 videojs('video-container', videojsOptions, function () {
51 .catch(err => console.error(err))