]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add duration in embed api playbackStatusUpdate
authorChocobozzz <me@florianbigard.com>
Wed, 8 Apr 2020 12:51:44 +0000 (14:51 +0200)
committerChocobozzz <me@florianbigard.com>
Wed, 8 Apr 2020 12:52:28 +0000 (14:52 +0200)
client/src/standalone/player/package.json
client/src/standalone/videos/embed-api.ts
client/src/standalone/videos/test-embed.ts
support/doc/api/embeds.md

index ba36b8ad3c231f82d108655a1a84623b766d6df1..985097af52f6857db971ae171b7d8605dd398440 100644 (file)
@@ -1,7 +1,7 @@
 {
   "name": "@peertube/embed-api",
   "private": false,
-  "version": "0.0.3",
+  "version": "0.0.4",
   "description": "API to communicate with the PeerTube player embed",
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
index c5fbe07fa56c851cf60f01fdb9380ed66affe460..194465d4a4bcba934cb651f83f23b1290e63ebd7 100644 (file)
@@ -85,12 +85,14 @@ export class PeerTubeEmbedApi {
     setInterval(() => {
       const position = this.element.currentTime
       const volume = this.element.volume
+      const duration = this.element.duration
 
       this.channel.notify({
         method: 'playbackStatusUpdate',
         params: {
           position,
           volume,
+          duration: this.embed.player.duration(),
           playbackState: currentState
         }
       })
index 202e86667c646e32eb2a81b0f0edae7ee0f41dee..a4b54782c7e8927ab078c4750ba0bf3f1eb742ad 100644 (file)
@@ -8,7 +8,7 @@ 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)
index 80e03b487d23b94d068b05aa88a9bdb476d96c10..80d6c22793d34a18d8b6e6642d6bb37096230506 100644 (file)
@@ -113,12 +113,14 @@ You can subscribe to events by using `addEventListener()`. See above for details
 
 ## Event `playbackStatusUpdate`
 
-Fired every half second to provide the current status of playback. The parameter of the callback will resemble:
+Fired every half second to provide the current status of playback. 
+The parameter of the callback will resemble:
 
 ```json
 {
   "position": 22.3,
   "volume": 0.9,
+  "duration": "171.37499",
   "playbackState": "playing"
 }
 ```