diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-27 14:44:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-27 14:44:34 +0200 |
commit | 39c0ceee8b6e7fab441dea1ad1699fe8d18f3b27 (patch) | |
tree | 1c0c3e51036f35b0efa797cbaea33fa3fa50ca8c /client/src/assets | |
parent | 9dfbf73576fdcc40d5dc956c5fe56e0dffe44ca8 (diff) | |
download | PeerTube-39c0ceee8b6e7fab441dea1ad1699fe8d18f3b27.tar.gz PeerTube-39c0ceee8b6e7fab441dea1ad1699fe8d18f3b27.tar.zst PeerTube-39c0ceee8b6e7fab441dea1ad1699fe8d18f3b27.zip |
Fix player error modal
Not hidden when we change the video
Diffstat (limited to 'client/src/assets')
-rw-r--r-- | client/src/assets/player/shared/peertube/peertube-plugin.ts | 22 | ||||
-rw-r--r-- | client/src/assets/player/shared/web-video/web-video-plugin.ts | 7 |
2 files changed, 23 insertions, 6 deletions
diff --git a/client/src/assets/player/shared/peertube/peertube-plugin.ts b/client/src/assets/player/shared/peertube/peertube-plugin.ts index 6c83d22bf..f93593415 100644 --- a/client/src/assets/player/shared/peertube/peertube-plugin.ts +++ b/client/src/assets/player/shared/peertube/peertube-plugin.ts | |||
@@ -36,6 +36,8 @@ class PeerTubePlugin extends Plugin { | |||
36 | private mouseInControlBar = false | 36 | private mouseInControlBar = false |
37 | private mouseInSettings = false | 37 | private mouseInSettings = false |
38 | 38 | ||
39 | private errorModal: videojs.ModalDialog | ||
40 | |||
39 | private videoViewOnPlayHandler: (...args: any[]) => void | 41 | private videoViewOnPlayHandler: (...args: any[]) => void |
40 | private videoViewOnSeekedHandler: (...args: any[]) => void | 42 | private videoViewOnSeekedHandler: (...args: any[]) => void |
41 | private videoViewOnEndedHandler: (...args: any[]) => void | 43 | private videoViewOnEndedHandler: (...args: any[]) => void |
@@ -109,6 +111,8 @@ class PeerTubePlugin extends Plugin { | |||
109 | 111 | ||
110 | this.player.on('video-change', () => { | 112 | this.player.on('video-change', () => { |
111 | this.initOnVideoChange() | 113 | this.initOnVideoChange() |
114 | |||
115 | this.hideFatalError() | ||
112 | }) | 116 | }) |
113 | }) | 117 | }) |
114 | } | 118 | } |
@@ -130,6 +134,11 @@ class PeerTubePlugin extends Plugin { | |||
130 | } | 134 | } |
131 | 135 | ||
132 | displayFatalError () { | 136 | displayFatalError () { |
137 | // Already displayed an error | ||
138 | if (this.errorModal) return | ||
139 | |||
140 | debugLogger('Display fatal error') | ||
141 | |||
133 | this.player.loadingSpinner.hide() | 142 | this.player.loadingSpinner.hide() |
134 | 143 | ||
135 | const buildModal = (error: MediaError) => { | 144 | const buildModal = (error: MediaError) => { |
@@ -150,17 +159,24 @@ class PeerTubePlugin extends Plugin { | |||
150 | return wrapper | 159 | return wrapper |
151 | } | 160 | } |
152 | 161 | ||
153 | const modal = this.player.createModal(buildModal(this.player.error()), { | 162 | this.errorModal = this.player.createModal(buildModal(this.player.error()), { |
154 | temporary: false, | 163 | temporary: true, |
155 | uncloseable: true | 164 | uncloseable: true |
156 | }) | 165 | }) |
157 | modal.addClass('vjs-custom-error-display') | 166 | this.errorModal.addClass('vjs-custom-error-display') |
158 | 167 | ||
159 | this.player.addClass('vjs-error-display-enabled') | 168 | this.player.addClass('vjs-error-display-enabled') |
160 | } | 169 | } |
161 | 170 | ||
162 | hideFatalError () { | 171 | hideFatalError () { |
172 | if (!this.errorModal) return | ||
173 | |||
174 | debugLogger('Hiding fatal error') | ||
175 | |||
163 | this.player.removeClass('vjs-error-display-enabled') | 176 | this.player.removeClass('vjs-error-display-enabled') |
177 | this.player.removeChild(this.errorModal) | ||
178 | this.errorModal.close() | ||
179 | this.errorModal = undefined | ||
164 | } | 180 | } |
165 | 181 | ||
166 | private initializePlayer () { | 182 | private initializePlayer () { |
diff --git a/client/src/assets/player/shared/web-video/web-video-plugin.ts b/client/src/assets/player/shared/web-video/web-video-plugin.ts index d09b5a724..b839062f2 100644 --- a/client/src/assets/player/shared/web-video/web-video-plugin.ts +++ b/client/src/assets/player/shared/web-video/web-video-plugin.ts | |||
@@ -65,9 +65,10 @@ class WebVideoPlugin extends Plugin { | |||
65 | const playbackRate = this.player.playbackRate() | 65 | const playbackRate = this.player.playbackRate() |
66 | const currentTime = this.player.currentTime() | 66 | const currentTime = this.player.currentTime() |
67 | 67 | ||
68 | // Enable error display now this is our last fallback | 68 | if (!this.onErrorHandler) { |
69 | this.onErrorHandler = () => this.player.peertube().displayFatalError() | 69 | this.onErrorHandler = () => this.player.peertube().displayFatalError() |
70 | this.player.one('error', this.onErrorHandler) | 70 | this.player.one('error', this.onErrorHandler) |
71 | } | ||
71 | 72 | ||
72 | let httpUrl = this.currentVideoFile.fileUrl | 73 | let httpUrl = this.currentVideoFile.fileUrl |
73 | 74 | ||