]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/standalone/videos/test-embed.ts
Improve live player responsive
[github/Chocobozzz/PeerTube.git] / client / src / standalone / videos / test-embed.ts
index 24cb62230bcf1b6b35df0e7613aca8a12514f51e..5f8e97562534589e7a75410228fe4c6a7e123455 100644 (file)
@@ -1,14 +1,19 @@
 import './test-embed.scss'
+import { PeerTubeResolution, PlayerEventType } from '../player/definitions'
 import { PeerTubePlayer } from '../player/player'
-import { PeerTubeResolution, PlayerEventType, PeerTubeTextTrack } from '../player/definitions'
 
 window.addEventListener('load', async () => {
   const urlParts = window.location.href.split('/')
   const lastPart = urlParts[ urlParts.length - 1 ]
-  const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ]
+
+  const isPlaylist = window.location.pathname.startsWith('/video-playlists/')
+
+  const elementId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ]
 
   const iframe = document.createElement('iframe')
-  iframe.src = `/videos/embed/${videoId}?api=1`
+  iframe.src = isPlaylist
+    ? `/videos/embed/${elementId}?api=1`
+    : `/video-playlists/embed/${elementId}?api=1`
 
   const mainElement = document.querySelector('#host')
   mainElement.appendChild(iframe)
@@ -32,6 +37,9 @@ window.addEventListener('load', async () => {
   monitoredEvents.forEach(e => {
     player.addEventListener(e as PlayerEventType, (param) => console.log(`PLAYER: event '${e}' received`, param))
     console.log(`PLAYER: now listening for event '${e}'`)
+
+    player.getCurrentPosition()
+      .then(position => document.getElementById('playlist-position').innerHTML = position + '')
   })
 
   let playbackRates: number[] = []