diff options
Diffstat (limited to 'support/doc')
-rw-r--r-- | support/doc/api/embeds.md | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/support/doc/api/embeds.md b/support/doc/api/embeds.md index 069882bfe..1dd1443e7 100644 --- a/support/doc/api/embeds.md +++ b/support/doc/api/embeds.md | |||
@@ -49,131 +49,131 @@ player.seek(32) | |||
49 | player.pause() | 49 | player.pause() |
50 | ``` | 50 | ``` |
51 | 51 | ||
52 | # URL parameters | 52 | ## Embed URL parameters |
53 | 53 | ||
54 | You can customize PeerTube player by specifying URL query parameters. | 54 | You can customize PeerTube player by specifying URL query parameters. |
55 | For example `https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a??start=1s&stop=18s&loop=1&autoplay=1&muted=1&warningTitle=0&controlBar=0&peertubeLink=0&p2p=0` | 55 | For example `https://my-instance.example.com/videos/embed/52a10666-3a18-4e73-93da-e8d3c12c305a??start=1s&stop=18s&loop=1&autoplay=1&muted=1&warningTitle=0&controlBar=0&peertubeLink=0&p2p=0` |
56 | 56 | ||
57 | ## start | 57 | ### start |
58 | 58 | ||
59 | Start the video at a specific time. | 59 | Start the video at a specific time. |
60 | Value must be raw seconds or a duration (`3m4s`) | 60 | Value must be raw seconds or a duration (`3m4s`) |
61 | 61 | ||
62 | ## stop | 62 | ### stop |
63 | 63 | ||
64 | Stop the video at a specific time. | 64 | Stop the video at a specific time. |
65 | Value must be raw seconds or a duration (`54s`) | 65 | Value must be raw seconds or a duration (`54s`) |
66 | 66 | ||
67 | ## controls | 67 | ### controls |
68 | 68 | ||
69 | Mimics video HTML element `controls` attribute, meaning that all controls (including big play button, control bar, etc.) will be removed. | 69 | Mimics video HTML element `controls` attribute, meaning that all controls (including big play button, control bar, etc.) will be removed. |
70 | It can be useful if you want to have a full control of the PeerTube player. | 70 | It can be useful if you want to have a full control of the PeerTube player. |
71 | 71 | ||
72 | Value must be `0` or `1`. | 72 | Value must be `0` or `1`. |
73 | 73 | ||
74 | ## controlBar | 74 | ### controlBar |
75 | 75 | ||
76 | Hide control bar when the video is played. | 76 | Hide control bar when the video is played. |
77 | 77 | ||
78 | Value must be `0` or `1`. | 78 | Value must be `0` or `1`. |
79 | 79 | ||
80 | ## peertubeLink | 80 | ### peertubeLink |
81 | 81 | ||
82 | Hide PeerTube instance link in control bar. | 82 | Hide PeerTube instance link in control bar. |
83 | 83 | ||
84 | Value must be `0` or `1`. | 84 | Value must be `0` or `1`. |
85 | 85 | ||
86 | ## muted | 86 | ### muted |
87 | 87 | ||
88 | Mute the video by default. | 88 | Mute the video by default. |
89 | 89 | ||
90 | Value must be `0` or `1`. | 90 | Value must be `0` or `1`. |
91 | 91 | ||
92 | ## loop | 92 | ### loop |
93 | 93 | ||
94 | Automatically start again the video when it ends. | 94 | Automatically start again the video when it ends. |
95 | 95 | ||
96 | Value must be `0` or `1`. | 96 | Value must be `0` or `1`. |
97 | 97 | ||
98 | ## subtitle | 98 | ### subtitle |
99 | 99 | ||
100 | Auto select a subtitle by default. | 100 | Auto select a subtitle by default. |
101 | 101 | ||
102 | Value must be a valid subtitle ISO code (`fr`, `en`, etc.). | 102 | Value must be a valid subtitle ISO code (`fr`, `en`, etc.). |
103 | 103 | ||
104 | ## autoplay | 104 | ### autoplay |
105 | 105 | ||
106 | Try to automatically play the video. | 106 | Try to automatically play the video. |
107 | Most web browsers disable video autoplay if the user did not interact with the video. You can try to bypass this limitation by muting the video | 107 | Most web browsers disable video autoplay if the user did not interact with the video. You can try to bypass this limitation by muting the video |
108 | 108 | ||
109 | Value must be `0` or `1`. | 109 | Value must be `0` or `1`. |
110 | 110 | ||
111 | ## title | 111 | ### title |
112 | 112 | ||
113 | Hide embed title. | 113 | Hide embed title. |
114 | 114 | ||
115 | Value must be `0` or `1`. | 115 | Value must be `0` or `1`. |
116 | 116 | ||
117 | ## warningTitle | 117 | ### warningTitle |
118 | 118 | ||
119 | Hide P2P warning title. | 119 | Hide P2P warning title. |
120 | 120 | ||
121 | Value must be `0` or `1`. | 121 | Value must be `0` or `1`. |
122 | 122 | ||
123 | ## p2p | 123 | ### p2p |
124 | 124 | ||
125 | Disable P2P. | 125 | Disable P2P. |
126 | 126 | ||
127 | Value must be `0` or `1`. | 127 | Value must be `0` or `1`. |
128 | 128 | ||
129 | ## bigPlayBackgroundColor | 129 | ### bigPlayBackgroundColor |
130 | 130 | ||
131 | Customize big play button background color. | 131 | Customize big play button background color. |
132 | 132 | ||
133 | Value must be a valid color (`red` or `rgba(100, 100, 100, 0.5)`). | 133 | Value must be a valid color (`red` or `rgba(100, 100, 100, 0.5)`). |
134 | 134 | ||
135 | ## foregroundColor | 135 | ### foregroundColor |
136 | 136 | ||
137 | Customize embed font color. | 137 | Customize embed font color. |
138 | 138 | ||
139 | Value must be a valid color (`red` or `rgba(100, 100, 100, 0.5)`). | 139 | Value must be a valid color (`red` or `rgba(100, 100, 100, 0.5)`). |
140 | 140 | ||
141 | ## mode | 141 | ### mode |
142 | 142 | ||
143 | Force a specific player engine. | 143 | Force a specific player engine. |
144 | 144 | ||
145 | Value must be a valid mode (`webtorrent` or `p2p-media-loader`). | 145 | Value must be a valid mode (`webtorrent` or `p2p-media-loader`). |
146 | 146 | ||
147 | ## api | 147 | ### api |
148 | 148 | ||
149 | Enable embed JavaScript API (see methods below). | 149 | Enable embed JavaScript API (see methods below). |
150 | 150 | ||
151 | Value must be `0` or `1`. | 151 | Value must be `0` or `1`. |
152 | 152 | ||
153 | 153 | ||
154 | # Methods | 154 | ## Embed methods |
155 | 155 | ||
156 | ## `play() : Promise<void>` | 156 | ### `play() : Promise<void>` |
157 | 157 | ||
158 | Starts playback, or resumes playback if it is paused. | 158 | Starts playback, or resumes playback if it is paused. |
159 | 159 | ||
160 | ## `pause() : Promise<void>` | 160 | ### `pause() : Promise<void>` |
161 | 161 | ||
162 | Pauses playback. | 162 | Pauses playback. |
163 | 163 | ||
164 | ## `seek(positionInSeconds : number)` | 164 | ### `seek(positionInSeconds : number)` |
165 | 165 | ||
166 | Seek to the given position, as specified in seconds into the video. | 166 | Seek to the given position, as specified in seconds into the video. |
167 | 167 | ||
168 | ## `addEventListener(eventName : string, handler : Function)` | 168 | ### `addEventListener(eventName : string, handler : Function)` |
169 | 169 | ||
170 | Add a listener for a specific event. See below for the available events. | 170 | Add a listener for a specific event. See below for the available events. |
171 | 171 | ||
172 | ## `removeEventListener(eventName : string, handler : Function)` | 172 | ### `removeEventListener(eventName : string, handler : Function)` |
173 | 173 | ||
174 | Remove a listener. | 174 | Remove a listener. |
175 | 175 | ||
176 | ## `getResolutions() : Promise<PeerTubeResolution[]>` | 176 | ### `getResolutions() : Promise<PeerTubeResolution[]>` |
177 | 177 | ||
178 | Get the available resolutions. A `PeerTubeResolution` looks like: | 178 | Get the available resolutions. A `PeerTubeResolution` looks like: |
179 | 179 | ||
@@ -188,56 +188,56 @@ Get the available resolutions. A `PeerTubeResolution` looks like: | |||
188 | 188 | ||
189 | `active` is true if the resolution is the currently selected resolution. | 189 | `active` is true if the resolution is the currently selected resolution. |
190 | 190 | ||
191 | ## `setResolution(resolutionId : number): Promise<void>` | 191 | ### `setResolution(resolutionId : number): Promise<void>` |
192 | 192 | ||
193 | Change the current resolution. Pass `-1` for automatic resolution (when available). | 193 | Change the current resolution. Pass `-1` for automatic resolution (when available). |
194 | Otherwise, `resolutionId` should be the ID of an object returned by `getResolutions()` | 194 | Otherwise, `resolutionId` should be the ID of an object returned by `getResolutions()` |
195 | 195 | ||
196 | ## `getPlaybackRates() : Promise<number[]>` | 196 | ### `getPlaybackRates() : Promise<number[]>` |
197 | 197 | ||
198 | Get the available playback rates, where `1` represents normal speed, `0.5` is half speed, `2` is double speed, etc. | 198 | Get the available playback rates, where `1` represents normal speed, `0.5` is half speed, `2` is double speed, etc. |
199 | 199 | ||
200 | ## `getPlaybackRates() : Promise<number>` | 200 | ### `getPlaybackRates() : Promise<number>` |
201 | 201 | ||
202 | Get the current playback rate. See `getPlaybackRates()` for more information. | 202 | Get the current playback rate. See `getPlaybackRates()` for more information. |
203 | 203 | ||
204 | ## `setPlaybackRate(rate: number) : Promise<void>` | 204 | ### `setPlaybackRate(rate: number) : Promise<void>` |
205 | 205 | ||
206 | Set the current playback rate. The passed rate should be a value as returned by `getPlaybackRates()`. | 206 | Set the current playback rate. The passed rate should be a value as returned by `getPlaybackRates()`. |
207 | 207 | ||
208 | ## `setVolume(factor: number) : Promise<void>` | 208 | ### `setVolume(factor: number) : Promise<void>` |
209 | 209 | ||
210 | Set the playback volume. Value should be between `0` and `1`. | 210 | Set the playback volume. Value should be between `0` and `1`. |
211 | 211 | ||
212 | ## `getVolume(): Promise<number>` | 212 | ### `getVolume(): Promise<number>` |
213 | 213 | ||
214 | Get the playback volume. Returns a value between `0` and `1`. | 214 | Get the playback volume. Returns a value between `0` and `1`. |
215 | 215 | ||
216 | ## `setCaption(id: string) : Promise<void>` | 216 | ### `setCaption(id: string) : Promise<void>` |
217 | 217 | ||
218 | Update current caption using the caption id. | 218 | Update current caption using the caption id. |
219 | 219 | ||
220 | ## `getCaptions(): Promise<{ id: string, label: string, src: string, mode: 'disabled' | 'showing' }>` | 220 | ### `getCaptions(): Promise<{ id: string, label: string, src: string, mode: 'disabled' | 'showing' }>` |
221 | 221 | ||
222 | Get video captions. | 222 | Get video captions. |
223 | 223 | ||
224 | ## `playNextVideo(): Promise<void>` | 224 | ### `playNextVideo(): Promise<void>` |
225 | 225 | ||
226 | Play next video in playlist. | 226 | Play next video in playlist. |
227 | 227 | ||
228 | ## `playPreviousVideo(): Promise<void>` | 228 | ### `playPreviousVideo(): Promise<void>` |
229 | 229 | ||
230 | Play previous video in playlist. | 230 | Play previous video in playlist. |
231 | 231 | ||
232 | ## `getCurrentPosition(): Promise<void>` | 232 | ### `getCurrentPosition(): Promise<void>` |
233 | 233 | ||
234 | Get current position in playlist (starts from 1). | 234 | Get current position in playlist (starts from 1). |
235 | 235 | ||
236 | # Events | 236 | ## Embed events |
237 | 237 | ||
238 | You can subscribe to events by using `addEventListener()`. See above for details. | 238 | You can subscribe to events by using `addEventListener()`. See above for details. |
239 | 239 | ||
240 | ## Event `playbackStatusUpdate` | 240 | ### Event `playbackStatusUpdate` |
241 | 241 | ||
242 | Fired every half second to provide the current status of playback. | 242 | Fired every half second to provide the current status of playback. |
243 | The parameter of the callback will resemble: | 243 | The parameter of the callback will resemble: |
@@ -256,14 +256,14 @@ The parameter of the callback will resemble: | |||
256 | The `volume` field contains the volume from `0` (silent) to `1` (full volume). | 256 | The `volume` field contains the volume from `0` (silent) to `1` (full volume). |
257 | The `playbackState` can be `unstarted`, `playing`, `paused` or `ended`. More states may be added later. | 257 | The `playbackState` can be `unstarted`, `playing`, `paused` or `ended`. More states may be added later. |
258 | 258 | ||
259 | ## Event `playbackStatusChange` | 259 | ### Event `playbackStatusChange` |
260 | 260 | ||
261 | Fired when playback transitions between states, such as `paused` and `playing`. More states may be added later. | 261 | Fired when playback transitions between states, such as `paused` and `playing`. More states may be added later. |
262 | 262 | ||
263 | ## Event `resolutionUpdate` | 263 | ### Event `resolutionUpdate` |
264 | 264 | ||
265 | Fired when the available resolutions have changed, or when the currently selected resolution has changed. Listener should call `getResolutions()` to get the updated information. | 265 | Fired when the available resolutions have changed, or when the currently selected resolution has changed. Listener should call `getResolutions()` to get the updated information. |
266 | 266 | ||
267 | ## Event `volumeChange` | 267 | ### Event `volumeChange` |
268 | 268 | ||
269 | Fired when the player volume changed. | 269 | Fired when the player volume changed. |