<div class="row">
<!-- We need the video container for videojs so we just hide it -->
<div id="video-element-wrapper">
+ <div *ngIf="remoteServerDown" class="remote-server-down">
+ Sorry, but this video is not available because the remote instance is not responding.
+ <br />
+ Please try again later.
+ </div>
</div>
<div i18n class="alert alert-warning" *ngIf="isVideoToTranscode()">
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 {
videoHTMLDescription = ''
likesBarTooltipText = ''
hasAlreadyAcceptedPrivacyConcern = false
+ remoteServerDown = false
private videojsLocaleLoaded = false
private otherVideos: Video[] = []
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 () {
// Re init attributes
this.descriptionLoading = false
this.completeDescriptionShown = false
+ this.remoteServerDown = false
this.updateOtherVideosDisplayed()
return this.addTorrent(this.torrent['xs'], previousVideoFile, newOptions, done)
}
- return console.warn(err)
+ // Remote instance is down
+ if (err.message.indexOf('http error from xs param') !== -1) {
+ this.handleError(err)
+ }
+
+ console.warn(err)
})
}
align-content: center;
justify-content: center;
text-align: center;
- background-color: #141313;
width: 100%;
height: 100%;
color: white;
element.parentElement.removeChild(element)
}
- displayError (videoElement: HTMLVideoElement, text: string) {
+ displayError (text: string) {
// Remove video element
- this.removeElement(videoElement)
+ if (this.videoElement) this.removeElement(this.videoElement)
document.title = 'Sorry - ' + text
errorText.innerHTML = text
}
- videoNotFound (videoElement: HTMLVideoElement) {
+ videoNotFound () {
const text = 'This video does not exist.'
- this.displayError(videoElement, text)
+ this.displayError(text)
}
- videoFetchError (videoElement: HTMLVideoElement) {
+ videoFetchError () {
const text = 'We cannot fetch the video. Please try again later.'
- this.displayError(videoElement, text)
+ this.displayError(text)
}
getParamToggle (params: URLSearchParams, name: string, defaultValue: boolean) {
])
if (!videoResponse.ok) {
- if (videoResponse.status === 404) return this.videoNotFound(this.videoElement)
+ if (videoResponse.status === 404) return this.videoNotFound()
- return this.videoFetchError(this.videoElement)
+ return this.videoFetchError()
}
const videoInfo: VideoDetails = await videoResponse.json()
this.playerOptions = videojsOptions
this.player = vjs(this.videoContainerId, videojsOptions, () => {
+ this.player.on('customError', (event, data) => this.handleError(data.err))
window[ 'videojsPlayer' ] = this.player
this.initializeApi()
})
}
+
+ private handleError (err: Error) {
+ if (err.message.indexOf('http error') !== -1) {
+ this.player.dispose()
+ this.videoElement = null
+ this.displayError('This video is not available because the remote instance is not responding.')
+ return
+ }
+ }
}
PeerTubeEmbed.main()