Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Prevent player crash on safari

Chocobozzz3f9decbd01d2
diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts
index 533ee1bb8f..5db7a2e556 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')
}