Don't start video after the element was removed from DOM (#9813)

This commit is contained in:
Bram Kragten 2021-08-16 05:43:00 +02:00 committed by GitHub
parent 2556b0d157
commit 456209dded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -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 =

View File

@ -211,6 +211,7 @@ export class HomeAssistantAppEl extends QuickBarMixin(HassElement) {
if (!this.hass!.connection.connected) {
return;
}
window.stop();
this.hass!.connection.suspend();
}