aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/shared/peertube/peertube-plugin.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/shared/peertube/peertube-plugin.ts')
-rw-r--r--client/src/assets/player/shared/peertube/peertube-plugin.ts32
1 files changed, 29 insertions, 3 deletions
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts
index 83c32415e..56de66998 100644
--- a/client/src/assets/player/shared/peertube/peertube-plugin.ts
+++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts
@@ -22,7 +22,7 @@ const Plugin = videojs.getPlugin('plugin')
22 22
23class PeerTubePlugin extends Plugin { 23class PeerTubePlugin extends Plugin {
24 private readonly videoViewUrl: string 24 private readonly videoViewUrl: string
25 private readonly authorizationHeader: string 25 private readonly authorizationHeader: () => string
26 26
27 private readonly videoUUID: string 27 private readonly videoUUID: string
28 private readonly startTime: number 28 private readonly startTime: number
@@ -125,6 +125,32 @@ class PeerTubePlugin extends Plugin {
125 } 125 }
126 126
127 displayFatalError () { 127 displayFatalError () {
128 this.player.loadingSpinner.hide()
129
130 const buildModal = (error: MediaError) => {
131 const localize = this.player.localize.bind(this.player)
132
133 const wrapper = document.createElement('div')
134 const header = document.createElement('h1')
135 header.innerText = localize('Failed to play video')
136 wrapper.appendChild(header)
137 const desc = document.createElement('div')
138 desc.innerText = localize('The video failed to play due to technical issues.')
139 wrapper.appendChild(desc)
140 const details = document.createElement('p')
141 details.classList.add('error-details')
142 details.innerText = error.message
143 wrapper.appendChild(details)
144
145 return wrapper
146 }
147
148 const modal = this.player.createModal(buildModal(this.player.error()), {
149 temporary: false,
150 uncloseable: true
151 })
152 modal.addClass('vjs-custom-error-display')
153
128 this.player.addClass('vjs-error-display-enabled') 154 this.player.addClass('vjs-error-display-enabled')
129 } 155 }
130 156
@@ -184,7 +210,7 @@ class PeerTubePlugin extends Plugin {
184 lastViewEvent = undefined 210 lastViewEvent = undefined
185 211
186 // Server won't save history, so save the video position in local storage 212 // Server won't save history, so save the video position in local storage
187 if (!this.authorizationHeader) { 213 if (!this.authorizationHeader()) {
188 saveVideoWatchHistory(this.videoUUID, currentTime) 214 saveVideoWatchHistory(this.videoUUID, currentTime)
189 } 215 }
190 }, this.CONSTANTS.USER_VIEW_VIDEO_INTERVAL) 216 }, this.CONSTANTS.USER_VIEW_VIDEO_INTERVAL)
@@ -202,7 +228,7 @@ class PeerTubePlugin extends Plugin {
202 'Content-type': 'application/json; charset=UTF-8' 228 'Content-type': 'application/json; charset=UTF-8'
203 }) 229 })
204 230
205 if (this.authorizationHeader) headers.set('Authorization', this.authorizationHeader) 231 if (this.authorizationHeader()) headers.set('Authorization', this.authorizationHeader())
206 232
207 return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers }) 233 return fetch(this.videoViewUrl, { method: 'POST', body: JSON.stringify(body), headers })
208 } 234 }