diff options
Diffstat (limited to 'client/src/assets/player/peertube-player-manager.ts')
-rw-r--r-- | client/src/assets/player/peertube-player-manager.ts | 22 |
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 | }) |