aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/peertube-player-manager.ts
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2022-09-28 11:52:23 +0200
committerGitHub <noreply@github.com>2022-09-28 11:52:23 +0200
commitf2a16d93b476aff16d5353e4d44350298ec7e01c (patch)
tree36c43eb3299c4a1137ca38dd1a564701a5a27236 /client/src/assets/player/peertube-player-manager.ts
parent43972ee466740e91b16c08fe106551657969e669 (diff)
downloadPeerTube-f2a16d93b476aff16d5353e4d44350298ec7e01c.tar.gz
PeerTube-f2a16d93b476aff16d5353e4d44350298ec7e01c.tar.zst
PeerTube-f2a16d93b476aff16d5353e4d44350298ec7e01c.zip
Handle network issues in video player (#5138)
* feat(client/player): handle network offline * feat(client/player): human friendly err msg * feat(client/player): handle broken resolutions When an error occurs for a resolution, remove the resolution and try with another resolution. * fix(client/player): prevent err handl when offline * fix(client/player): localize offline text
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r--client/src/assets/player/peertube-player-manager.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 0d4acc3d9..533ee1bb8 100644
--- a/client/src/assets/player/peertube-player-manager.ts
+++ b/client/src/assets/player/peertube-player-manager.ts
@@ -129,6 +129,28 @@ export class PeertubePlayerManager {
129 saveAverageBandwidth(data.bandwidthEstimate) 129 saveAverageBandwidth(data.bandwidthEstimate)
130 }) 130 })
131 131
132 const offlineNotificationElem = document.createElement('div')
133 offlineNotificationElem.classList.add('vjs-peertube-offline-notification')
134 offlineNotificationElem.innerText = player.localize('You seem to be offline and the video may not work')
135
136 const handleOnline = () => {
137 player.el().removeChild(offlineNotificationElem)
138 logger.info('The browser is online')
139 }
140
141 const handleOffline = () => {
142 player.el().appendChild(offlineNotificationElem)
143 logger.info('The browser is offline')
144 }
145
146 window.addEventListener('online', handleOnline)
147 window.addEventListener('offline', handleOffline)
148
149 player.on('dispose', () => {
150 window.removeEventListener('online', handleOnline)
151 window.removeEventListener('offline', handleOffline)
152 })
153
132 return res(player) 154 return res(player)
133 }) 155 })
134 }) 156 })