From 6d88de725321e77486788f64a2e2537f5e6ef0cd Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 16 Jul 2018 19:15:20 +0200 Subject: Correctly handle error when remote instance is down --- .../videos/+video-watch/video-watch.component.html | 5 ++++ .../videos/+video-watch/video-watch.component.scss | 32 ++++++++++++++++++---- .../videos/+video-watch/video-watch.component.ts | 13 +++++---- 3 files changed, 39 insertions(+), 11 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index f28134ece..21f8f5534 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html @@ -1,6 +1,11 @@
+
+ Sorry, but this video is not available because the remote instance is not responding. +
+ Please try again later. +
diff --git a/client/src/app/videos/+video-watch/video-watch.component.scss b/client/src/app/videos/+video-watch/video-watch.component.scss index 7c694f2e2..4ce17209f 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss @@ -5,15 +5,37 @@ background-color: #000; display: flex; justify-content: center; + height: 500px; - /deep/ .video-js { - width: 888px; - height: 500px; + @media screen and (max-width: 600px) { + width: 100vw; + height: calc(100vw / 1.7); // 16/9 + } + + .remote-server-down { + color: #fff; + display: flex; + flex-direction: column; + align-items: center; + text-align: center; + justify-content: center; + background-color: #141313; + width: 100%; + height: 100%; + font-size: 24px; + + @media screen and (max-width: 1000px) { + font-size: 20px; + } @media screen and (max-width: 600px) { - width: 100vw; - height: calc(100vw / 1.7); // 16/9 + font-size: 16px; } + } + + /deep/ .video-js { + width: 888px; + height: 100%; // VideoJS create an inner video player video { diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 601c6a38d..43afbae1a 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -57,6 +57,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { videoHTMLDescription = '' likesBarTooltipText = '' hasAlreadyAcceptedPrivacyConcern = false + remoteServerDown = false private videojsLocaleLoaded = false private otherVideos: Video[] = [] @@ -312,15 +313,14 @@ export class VideoWatchComponent implements OnInit, OnDestroy { const errorMessage: string = typeof err === 'string' ? err : err.message if (!errorMessage) return - let message = '' - + // Display a message in the video player instead of a notification if (errorMessage.indexOf('http error') !== -1) { - message = this.i18n('Cannot fetch video from server, maybe down.') - } else { - message = errorMessage + this.flushPlayer() + this.remoteServerDown = true + return } - this.notificationsService.error(this.i18n('Error'), message) + this.notificationsService.error(this.i18n('Error'), errorMessage) } private checkUserRating () { @@ -345,6 +345,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { // Re init attributes this.descriptionLoading = false this.completeDescriptionShown = false + this.remoteServerDown = false this.updateOtherVideosDisplayed() -- cgit v1.2.3