aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/standalone/videos/test-embed.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-05 14:16:39 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-07 08:58:29 +0200
commit9054a8b6e522dd8d46260dca85e9de94a2d806cf (patch)
tree5699e0c2853c17cbaef037eec4cb48cfbf0ec06d /client/src/standalone/videos/test-embed.ts
parent2a71d286cec31964e0b70b5a7c53bfad401af554 (diff)
downloadPeerTube-9054a8b6e522dd8d46260dca85e9de94a2d806cf.tar.gz
PeerTube-9054a8b6e522dd8d46260dca85e9de94a2d806cf.tar.zst
PeerTube-9054a8b6e522dd8d46260dca85e9de94a2d806cf.zip
Handle playlist methods in embed api
Diffstat (limited to 'client/src/standalone/videos/test-embed.ts')
-rw-r--r--client/src/standalone/videos/test-embed.ts14
1 files changed, 11 insertions, 3 deletions
diff --git a/client/src/standalone/videos/test-embed.ts b/client/src/standalone/videos/test-embed.ts
index 24cb62230..5f8e97562 100644
--- a/client/src/standalone/videos/test-embed.ts
+++ b/client/src/standalone/videos/test-embed.ts
@@ -1,14 +1,19 @@
1import './test-embed.scss' 1import './test-embed.scss'
2import { PeerTubeResolution, PlayerEventType } from '../player/definitions'
2import { PeerTubePlayer } from '../player/player' 3import { PeerTubePlayer } from '../player/player'
3import { PeerTubeResolution, PlayerEventType, PeerTubeTextTrack } from '../player/definitions'
4 4
5window.addEventListener('load', async () => { 5window.addEventListener('load', async () => {
6 const urlParts = window.location.href.split('/') 6 const urlParts = window.location.href.split('/')
7 const lastPart = urlParts[ urlParts.length - 1 ] 7 const lastPart = urlParts[ urlParts.length - 1 ]
8 const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ] 8
9 const isPlaylist = window.location.pathname.startsWith('/video-playlists/')
10
11 const elementId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ]
9 12
10 const iframe = document.createElement('iframe') 13 const iframe = document.createElement('iframe')
11 iframe.src = `/videos/embed/${videoId}?api=1` 14 iframe.src = isPlaylist
15 ? `/videos/embed/${elementId}?api=1`
16 : `/video-playlists/embed/${elementId}?api=1`
12 17
13 const mainElement = document.querySelector('#host') 18 const mainElement = document.querySelector('#host')
14 mainElement.appendChild(iframe) 19 mainElement.appendChild(iframe)
@@ -32,6 +37,9 @@ window.addEventListener('load', async () => {
32 monitoredEvents.forEach(e => { 37 monitoredEvents.forEach(e => {
33 player.addEventListener(e as PlayerEventType, (param) => console.log(`PLAYER: event '${e}' received`, param)) 38 player.addEventListener(e as PlayerEventType, (param) => console.log(`PLAYER: event '${e}' received`, param))
34 console.log(`PLAYER: now listening for event '${e}'`) 39 console.log(`PLAYER: now listening for event '${e}'`)
40
41 player.getCurrentPosition()
42 .then(position => document.getElementById('playlist-position').innerHTML = position + '')
35 }) 43 })
36 44
37 let playbackRates: number[] = [] 45 let playbackRates: number[] = []