]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - support/doc/api/embeds.md
Add "ended" embed API event
[github/Chocobozzz/PeerTube.git] / support / doc / api / embeds.md
index c2317a0309aec4daafd0b242ef49c397b8f01dee..a4236c521b90df2f2f5d977e235bc174b3b99014 100644 (file)
@@ -10,7 +10,8 @@ For instance, the playground URL for the above embed URL is `https://my-instance
 
 ## Quick Start
 
-Given an existing PeerTube embed `<iframe>`, one can use the PeerTube Embed API to control it by first including the library. You can include it via Yarn with:
+Given an existing PeerTube embed `<iframe>` **with API enabled** (`https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a?api=1`),
+one can use the PeerTube Embed API to control it by first including the library. You can include it via Yarn with:
 
 ```
 yarn add @peertube/embed-api
@@ -21,13 +22,31 @@ Now just use the `PeerTubePlayer` class exported by the module:
 ```typescript
 import { PeerTubePlayer } from '@peertube/embed-api'
 
+...
+```
+
+Or use the minified build from NPM CDN in your HTML file:
+
+```
+<script src="https://unpkg.com/@peertube/embed-api@0.0.1/build/player.min.js"></script>
+
+<script>
+  const PeerTubePlayer = window['PeerTubePlayer']
+
+  ...
+</script>
+```
+
+Then you can instantiate the player:
+
+```typescript
 let player = new PeerTubePlayer(document.querySelector('iframe'))
 await player.ready // wait for the player to be ready
 
 // now you can use it!
 player.play()
 player.seek(32)
-player.stop()
+player.pause()
 ```
 
 # Methods
@@ -56,7 +75,7 @@ Get the available resolutions. A `PeerTubeResolution` looks like:
 {
     "id": 3,
     "label": "720p",
-    "src": "//src-url-here",
+    "height": "720",
     "active": true
 }
 ```
@@ -87,18 +106,11 @@ Set the playback volume. Value should be between `0` and `1`.
 ## `getVolume(): Promise<number>`
 
 Get the playback volume. Returns a value between `0` and `1`.
+
 # Events
 
 You can subscribe to events by using `addEventListener()`. See above for details.
 
-## Event `play`
-
-Fired when playback begins or is resumed after pausing.
-
-## Event `pause`
-
-Fired when playback is paused.
-
 ## Event `playbackStatusUpdate`
 
 Fired every half second to provide the current status of playback. The parameter of the callback will resemble:
@@ -111,11 +123,12 @@ Fired every half second to provide the current status of playback. The parameter
 }
 ```
 
-The `volume` field contains the volume from `0` (silent) to `1` (full volume). The `playbackState` can be `playing` or `paused`. More states may be added later.
+The `volume` field contains the volume from `0` (silent) to `1` (full volume).
+The `playbackState` can be `unstarted`, `playing`, `paused` or `ended`. More states may be added later.
 
 ## Event `playbackStatusChange`
 
-Fired when playback transitions between states, such as `pausing` and `playing`. More states may be added later.
+Fired when playback transitions between states, such as `paused` and `playing`. More states may be added later.
 
 ## Event `resolutionUpdate`