]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/standalone/videos/test-embed.ts
Add duration in embed api playbackStatusUpdate
[github/Chocobozzz/PeerTube.git] / client / src / standalone / videos / test-embed.ts
index 8e83d92a928488b0ee47cac328d80f78c4a91944..a4b54782c7e8927ab078c4750ba0bf3f1eb742ad 100644 (file)
@@ -8,7 +8,8 @@ window.addEventListener('load', async () => {
   const videoId = lastPart.indexOf('?') === -1 ? lastPart : lastPart.split('?')[ 0 ]
 
   const iframe = document.createElement('iframe')
-  iframe.src = `/videos/embed/${videoId}?autoplay=1&controls=0&api=1`
+  iframe.src = `/videos/embed/${videoId}?api=1`
+
   const mainElement = document.querySelector('#host')
   mainElement.appendChild(iframe)
 
@@ -29,7 +30,7 @@ window.addEventListener('load', async () => {
   ]
 
   monitoredEvents.forEach(e => {
-    player.addEventListener(e as PlayerEventType, () => console.log(`PLAYER: event '${e}' received`))
+    player.addEventListener(e as PlayerEventType, (param) => console.log(`PLAYER: event '${e}' received`, param))
     console.log(`PLAYER: now listening for event '${e}'`)
   })
 
@@ -93,4 +94,12 @@ window.addEventListener('load', async () => {
     resolutions => updateResolutions(resolutions))
   player.addEventListener('resolutionUpdate',
     resolutions => updateResolutions(resolutions))
+
+  const updateVolume = (volume: number) => {
+    const volumeEl = document.getElementById('volume')
+    volumeEl.innerText = (volume * 100) + '%'
+  }
+
+  player.getVolume().then(volume => updateVolume(volume))
+  player.addEventListener('volumeChange', volume => updateVolume(volume))
 })