From 456209ddeda2f0cb12ca1d5a5868693f472cea7e Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 16 Aug 2021 05:43:00 +0200 Subject: [PATCH] Don't start video after the element was removed from DOM (#9813) --- src/components/ha-hls-player.ts | 9 +++++++++ src/layouts/home-assistant.ts | 1 + 2 files changed, 10 insertions(+) diff --git a/src/components/ha-hls-player.ts b/src/components/ha-hls-player.ts index 1985605323..d621e79d80 100644 --- a/src/components/ha-hls-player.ts +++ b/src/components/ha-hls-player.ts @@ -98,6 +98,11 @@ class HaHLSPlayer extends LitElement { const Hls: typeof HlsType = (await import("hls.js/dist/hls.light.min")) .default; + + if (!this.isConnected) { + return; + } + let hlsSupported = Hls.isSupported(); if (!hlsSupported) { @@ -115,6 +120,10 @@ class HaHLSPlayer extends LitElement { const useExoPlayer = await useExoPlayerPromise; const masterPlaylist = await (await masterPlaylistPromise).text(); + if (!this.isConnected) { + return; + } + // Parse playlist assuming it is a master playlist. Match group 1 is whether hevc, match group 2 is regular playlist url // See https://tools.ietf.org/html/rfc8216 for HLS spec details const playlistRegexp = diff --git a/src/layouts/home-assistant.ts b/src/layouts/home-assistant.ts index b189d39b60..2468644605 100644 --- a/src/layouts/home-assistant.ts +++ b/src/layouts/home-assistant.ts @@ -211,6 +211,7 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) { if (!this.hass!.connection.connected) { return; } + window.stop(); this.hass!.connection.suspend(); }