From 3f9decbd01d25f1b1805e2764dff4beae7d36c19 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 28 Oct 2022 15:44:19 +0200 Subject: Prevent player crash on safari --- client/src/assets/player/peertube-player-manager.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'client/src/assets') diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index 533ee1bb8..5db7a2e55 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts @@ -133,13 +133,23 @@ export class PeertubePlayerManager { offlineNotificationElem.classList.add('vjs-peertube-offline-notification') offlineNotificationElem.innerText = player.localize('You seem to be offline and the video may not work') + let offlineNotificationElemAdded = false + const handleOnline = () => { + if (!offlineNotificationElemAdded) return + player.el().removeChild(offlineNotificationElem) + offlineNotificationElemAdded = false + logger.info('The browser is online') } const handleOffline = () => { + if (offlineNotificationElemAdded) return + player.el().appendChild(offlineNotificationElem) + offlineNotificationElemAdded = true + logger.info('The browser is offline') } -- cgit v1.2.3