Fix HLS player cleanup (null access to removeAttribute) (#11074)

This commit is contained in:
Philip Allgaier 2022-01-07 17:44:57 +01:00 committed by GitHub
parent 5261d583a8
commit 595e13ecac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View File

@ -98,7 +98,6 @@ class HaHLSPlayer extends LitElement {
private async _startHls(): Promise<void> { private async _startHls(): Promise<void> {
this._error = undefined; this._error = undefined;
const videoEl = this._videoEl;
const useExoPlayerPromise = this._getUseExoPlayer(); const useExoPlayerPromise = this._getUseExoPlayer();
const masterPlaylistPromise = fetch(this.url); const masterPlaylistPromise = fetch(this.url);
@ -113,7 +112,7 @@ class HaHLSPlayer extends LitElement {
if (!hlsSupported) { if (!hlsSupported) {
hlsSupported = hlsSupported =
videoEl.canPlayType("application/vnd.apple.mpegurl") !== ""; this._videoEl.canPlayType("application/vnd.apple.mpegurl") !== "";
} }
if (!hlsSupported) { if (!hlsSupported) {
@ -151,9 +150,9 @@ class HaHLSPlayer extends LitElement {
if (useExoPlayer && match !== null && match[1] !== undefined) { if (useExoPlayer && match !== null && match[1] !== undefined) {
this._renderHLSExoPlayer(playlist_url); this._renderHLSExoPlayer(playlist_url);
} else if (Hls.isSupported()) { } else if (Hls.isSupported()) {
this._renderHLSPolyfill(videoEl, Hls, playlist_url); this._renderHLSPolyfill(this._videoEl, Hls, playlist_url);
} else { } else {
this._renderHLSNative(videoEl, playlist_url); this._renderHLSNative(this._videoEl, playlist_url);
} }
} }
@ -261,9 +260,10 @@ class HaHLSPlayer extends LitElement {
this.hass!.auth.external!.fireMessage({ type: "exoplayer/stop" }); this.hass!.auth.external!.fireMessage({ type: "exoplayer/stop" });
this._exoPlayer = false; this._exoPlayer = false;
} }
const videoEl = this._videoEl; if (this._videoEl) {
videoEl.removeAttribute("src"); this._videoEl.removeAttribute("src");
videoEl.load(); this._videoEl.load();
}
} }
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {

View File

@ -136,9 +136,8 @@ class HaWebRtcPlayer extends LitElement {
this._remoteStream = undefined; this._remoteStream = undefined;
} }
if (this._videoEl) { if (this._videoEl) {
const videoEl = this._videoEl; this._videoEl.removeAttribute("src");
videoEl.removeAttribute("src"); this._videoEl.load();
videoEl.load();
} }
if (this._peerConnection) { if (this._peerConnection) {
this._peerConnection.close(); this._peerConnection.close();