]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/standalone/videos/embed.ts
Fix embed lint
[github/Chocobozzz/PeerTube.git] / client / src / standalone / videos / embed.ts
CommitLineData
202e7223
C
1import './embed.scss'
2
63c4db6d 3import * as videojs from 'video.js'
2ccaeeb3 4import 'videojs-hotkeys'
aa8b6df4 5import '../../assets/player/peertube-videojs-plugin'
202e7223 6import 'videojs-dock/dist/videojs-dock.es.js'
404b54e1 7import { VideoDetails } from '../../../../shared'
202e7223 8
a16aee73 9async function loadVideoInfo (videoId: string): Promise<VideoDetails> {
f2f1118f 10 const response = await fetch(window.location.origin + '/api/v1/videos/' + videoId)
a16aee73 11 return response.json()
202e7223
C
12}
13
202e7223
C
14const urlParts = window.location.href.split('/')
15const videoId = urlParts[urlParts.length - 1]
16
f2f1118f
F
17loadVideoInfo(videoId)
18 .then(videoInfo => {
19 const videoElement = document.getElementById('video-container') as HTMLVideoElement
20 const previewUrl = window.location.origin + videoInfo.previewPath
21 videoElement.poster = previewUrl
22
23 const videojsOptions = {
24 controls: true,
25 autoplay: false,
26 plugins: {
27 peertube: {
28 videoFiles: videoInfo.files,
29 playerElement: videoElement,
30 peerTubeLink: true
31 },
32 hotkeys: {
33 enableVolumeScroll: false
34 }
234b535d 35 }
aa8b6df4 36 }
f2f1118f
F
37 videojs('video-container', videojsOptions, function () {
38 const player = this
202e7223 39
f2f1118f
F
40 player.dock({
41 title: videoInfo.name
42 })
202e7223 43 })
202e7223 44 })
a16aee73 45 .catch(err => console.error(err))