]>
Commit | Line | Data |
---|---|---|
202e7223 C |
1 | import './embed.scss' |
2 | ||
63c4db6d | 3 | import * as videojs from 'video.js' |
2ccaeeb3 | 4 | import 'videojs-hotkeys' |
aa8b6df4 | 5 | import '../../assets/player/peertube-videojs-plugin' |
202e7223 | 6 | import 'videojs-dock/dist/videojs-dock.es.js' |
404b54e1 | 7 | import { VideoDetails } from '../../../../shared' |
202e7223 | 8 | |
a16aee73 | 9 | async 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 |
14 | const urlParts = window.location.href.split('/') |
15 | const videoId = urlParts[urlParts.length - 1] | |
16 | ||
f2f1118f F |
17 | loadVideoInfo(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)) |