diff options
author | Chocobozzz <me@florianbigard.com> | 2020-05-06 11:54:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-05-06 11:54:33 +0200 |
commit | 1151f5210c0e7665ec6714e73261f299e6fe757b (patch) | |
tree | 4d43e548a7d9ce7e7c4ecf6a257e9c8e395c3f95 /client/src/standalone/videos/test-embed.ts | |
parent | fc8aabd0bf38441c0591f21b9b435b52e99ffc23 (diff) | |
download | PeerTube-1151f5210c0e7665ec6714e73261f299e6fe757b.tar.gz PeerTube-1151f5210c0e7665ec6714e73261f299e6fe757b.tar.zst PeerTube-1151f5210c0e7665ec6714e73261f299e6fe757b.zip |
Add ability to update embed captions
Diffstat (limited to 'client/src/standalone/videos/test-embed.ts')
-rw-r--r-- | client/src/standalone/videos/test-embed.ts | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts index a4b54782c..24cb62230 100644 --- a/client/src/standalone/videos/test-embed.ts +++ b/client/src/standalone/videos/test-embed.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import './test-embed.scss' | 1 | import './test-embed.scss' |
2 | import { PeerTubePlayer } from '../player/player' | 2 | import { PeerTubePlayer } from '../player/player' |
3 | import { PeerTubeResolution, PlayerEventType } from '../player/definitions' | 3 | import { PeerTubeResolution, PlayerEventType, PeerTubeTextTrack } from '../player/definitions' |
4 | 4 | ||
5 | window.addEventListener('load', async () => { | 5 | window.addEventListener('load', async () => { |
6 | const urlParts = window.location.href.split('/') | 6 | const urlParts = window.location.href.split('/') |
@@ -67,6 +67,36 @@ window.addEventListener('load', async () => { | |||
67 | updateRates() | 67 | updateRates() |
68 | }) | 68 | }) |
69 | 69 | ||
70 | const updateCaptions = async () => { | ||
71 | const captions = await player.getCaptions() | ||
72 | |||
73 | const captionEl = document.querySelector('#caption-list') | ||
74 | captionEl.innerHTML = '' | ||
75 | |||
76 | captions.forEach(c => { | ||
77 | console.log(c) | ||
78 | |||
79 | if (c.mode === 'showing') { | ||
80 | const itemEl = document.createElement('strong') | ||
81 | itemEl.innerText = `${c.label} (active)` | ||
82 | itemEl.style.display = 'block' | ||
83 | captionEl.appendChild(itemEl) | ||
84 | } else { | ||
85 | const itemEl = document.createElement('a') | ||
86 | itemEl.href = 'javascript:;' | ||
87 | itemEl.innerText = c.label | ||
88 | itemEl.addEventListener('click', () => { | ||
89 | player.setCaption(c.id) | ||
90 | updateCaptions() | ||
91 | }) | ||
92 | itemEl.style.display = 'block' | ||
93 | captionEl.appendChild(itemEl) | ||
94 | } | ||
95 | }) | ||
96 | } | ||
97 | |||
98 | updateCaptions() | ||
99 | |||
70 | const updateResolutions = ((resolutions: PeerTubeResolution[]) => { | 100 | const updateResolutions = ((resolutions: PeerTubeResolution[]) => { |
71 | const resolutionListEl = document.querySelector('#resolution-list') | 101 | const resolutionListEl = document.querySelector('#resolution-list') |
72 | resolutionListEl.innerHTML = '' | 102 | resolutionListEl.innerHTML = '' |