X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fassets%2Fplayer%2Fshared%2Fpeertube%2Fpeertube-plugin.ts;h=a5d712d70dbd9e1340526e047b58b859afe2fe93;hb=38a3ccc7f8ad0ea94362b58c732af7c387ab46be;hp=a29a0921f755923501608406335fe07486dc8b54;hpb=b434d9282955fba0dfbad9d4e1fab619a96233a9;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index a29a0921f..a5d712d70 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts @@ -1,5 +1,6 @@ import debug from 'debug' import videojs from 'video.js' +import { logger } from '@root-helpers/logger' import { isMobile } from '@root-helpers/web-browser' import { timeToInt } from '@shared/core-utils' import { VideoView, VideoViewEvent } from '@shared/models/videos' @@ -15,7 +16,7 @@ import { import { PeerTubePluginOptions, VideoJSCaption } from '../../types' import { SettingsButton } from '../settings/settings-menu-button' -const logger = debug('peertube:player:peertube') +const debugLogger = debug('peertube:player:peertube') const Plugin = videojs.getPlugin('plugin') @@ -124,6 +125,32 @@ class PeerTubePlugin extends Plugin { } displayFatalError () { + this.player.loadingSpinner.hide() + + const buildModal = (error: MediaError) => { + const localize = this.player.localize.bind(this.player) + + const wrapper = document.createElement('div') + const header = document.createElement('h1') + header.innerText = localize('Failed to play video') + wrapper.appendChild(header) + const desc = document.createElement('div') + desc.innerText = localize('The video failed to play due to technical issues.') + wrapper.appendChild(desc) + const details = document.createElement('p') + details.classList.add('error-details') + details.innerText = error.message + wrapper.appendChild(details) + + return wrapper + } + + const modal = this.player.createModal(buildModal(this.player.error()), { + temporary: false, + uncloseable: true + }) + modal.addClass('vjs-custom-error-display') + this.player.addClass('vjs-error-display-enabled') } @@ -143,6 +170,8 @@ class PeerTubePlugin extends Plugin { this.listenFullScreenChange() } + // --------------------------------------------------------------------------- + private runUserViewing () { let lastCurrentTime = this.startTime let lastViewEvent: VideoViewEvent @@ -176,7 +205,7 @@ class PeerTubePlugin extends Plugin { lastCurrentTime = currentTime this.notifyUserIsWatching(currentTime, lastViewEvent) - .catch(err => console.error('Cannot notify user is watching.', err)) + .catch(err => logger.error('Cannot notify user is watching.', err)) lastViewEvent = undefined @@ -204,6 +233,8 @@ class PeerTubePlugin extends Plugin { return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers }) } + // --------------------------------------------------------------------------- + private listenFullScreenChange () { this.player.on('fullscreenchange', () => { if (this.player.isFullscreen()) this.player.focus() @@ -249,7 +280,7 @@ class PeerTubePlugin extends Plugin { (this.player as any).cache_.inactivityTimeout = timeout this.player.options_.inactivityTimeout = timeout - logger('Set player inactivity to ' + timeout) + debugLogger('Set player inactivity to ' + timeout) } private initCaptions () {