diff options
Diffstat (limited to 'client/src/standalone/videos')
-rw-r--r-- | client/src/standalone/videos/embed.scss | 1 | ||||
-rw-r--r-- | client/src/standalone/videos/embed.ts | 26 |
2 files changed, 18 insertions, 9 deletions
diff --git a/client/src/standalone/videos/embed.scss b/client/src/standalone/videos/embed.scss index f92a1f54a..30650538f 100644 --- a/client/src/standalone/videos/embed.scss +++ b/client/src/standalone/videos/embed.scss | |||
@@ -63,7 +63,6 @@ html, body { | |||
63 | align-content: center; | 63 | align-content: center; |
64 | justify-content: center; | 64 | justify-content: center; |
65 | text-align: center; | 65 | text-align: center; |
66 | background-color: #141313; | ||
67 | width: 100%; | 66 | width: 100%; |
68 | height: 100%; | 67 | height: 100%; |
69 | color: white; | 68 | color: white; |
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index b2809467d..cb05ec2b5 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -188,9 +188,9 @@ class PeerTubeEmbed { | |||
188 | element.parentElement.removeChild(element) | 188 | element.parentElement.removeChild(element) |
189 | } | 189 | } |
190 | 190 | ||
191 | displayError (videoElement: HTMLVideoElement, text: string) { | 191 | displayError (text: string) { |
192 | // Remove video element | 192 | // Remove video element |
193 | this.removeElement(videoElement) | 193 | if (this.videoElement) this.removeElement(this.videoElement) |
194 | 194 | ||
195 | document.title = 'Sorry - ' + text | 195 | document.title = 'Sorry - ' + text |
196 | 196 | ||
@@ -201,14 +201,14 @@ class PeerTubeEmbed { | |||
201 | errorText.innerHTML = text | 201 | errorText.innerHTML = text |
202 | } | 202 | } |
203 | 203 | ||
204 | videoNotFound (videoElement: HTMLVideoElement) { | 204 | videoNotFound () { |
205 | const text = 'This video does not exist.' | 205 | const text = 'This video does not exist.' |
206 | this.displayError(videoElement, text) | 206 | this.displayError(text) |
207 | } | 207 | } |
208 | 208 | ||
209 | videoFetchError (videoElement: HTMLVideoElement) { | 209 | videoFetchError () { |
210 | const text = 'We cannot fetch the video. Please try again later.' | 210 | const text = 'We cannot fetch the video. Please try again later.' |
211 | this.displayError(videoElement, text) | 211 | this.displayError(text) |
212 | } | 212 | } |
213 | 213 | ||
214 | getParamToggle (params: URLSearchParams, name: string, defaultValue: boolean) { | 214 | getParamToggle (params: URLSearchParams, name: string, defaultValue: boolean) { |
@@ -264,9 +264,9 @@ class PeerTubeEmbed { | |||
264 | ]) | 264 | ]) |
265 | 265 | ||
266 | if (!videoResponse.ok) { | 266 | if (!videoResponse.ok) { |
267 | if (videoResponse.status === 404) return this.videoNotFound(this.videoElement) | 267 | if (videoResponse.status === 404) return this.videoNotFound() |
268 | 268 | ||
269 | return this.videoFetchError(this.videoElement) | 269 | return this.videoFetchError() |
270 | } | 270 | } |
271 | 271 | ||
272 | const videoInfo: VideoDetails = await videoResponse.json() | 272 | const videoInfo: VideoDetails = await videoResponse.json() |
@@ -303,6 +303,7 @@ class PeerTubeEmbed { | |||
303 | 303 | ||
304 | this.playerOptions = videojsOptions | 304 | this.playerOptions = videojsOptions |
305 | this.player = vjs(this.videoContainerId, videojsOptions, () => { | 305 | this.player = vjs(this.videoContainerId, videojsOptions, () => { |
306 | this.player.on('customError', (event, data) => this.handleError(data.err)) | ||
306 | 307 | ||
307 | window[ 'videojsPlayer' ] = this.player | 308 | window[ 'videojsPlayer' ] = this.player |
308 | 309 | ||
@@ -318,6 +319,15 @@ class PeerTubeEmbed { | |||
318 | this.initializeApi() | 319 | this.initializeApi() |
319 | }) | 320 | }) |
320 | } | 321 | } |
322 | |||
323 | private handleError (err: Error) { | ||
324 | if (err.message.indexOf('http error') !== -1) { | ||
325 | this.player.dispose() | ||
326 | this.videoElement = null | ||
327 | this.displayError('This video is not available because the remote instance is not responding.') | ||
328 | return | ||
329 | } | ||
330 | } | ||
321 | } | 331 | } |
322 | 332 | ||
323 | PeerTubeEmbed.main() | 333 | PeerTubeEmbed.main() |