This commit is contained in:
Paulus Schoutsen 2019-03-12 19:41:02 -07:00 committed by GitHub
parent c9eea4acc1
commit e2ed1a9fd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,6 +10,7 @@ type HLSModule = typeof import("hls.js");
class MoreInfoCamera extends UpdatingElement { class MoreInfoCamera extends UpdatingElement {
@property() public hass?: HomeAssistant; @property() public hass?: HomeAssistant;
@property() public stateObj?: CameraEntity; @property() public stateObj?: CameraEntity;
private _hlsPolyfillInstance?: Hls;
public disconnectedCallback() { public disconnectedCallback() {
super.disconnectedCallback(); super.disconnectedCallback();
@ -100,6 +101,7 @@ class MoreInfoCamera extends UpdatingElement {
url: string url: string
) { ) {
const hls = new Hls(); const hls = new Hls();
this._hlsPolyfillInstance = hls;
await new Promise((resolve) => { await new Promise((resolve) => {
hls.on(Hls.Events.MEDIA_ATTACHED, resolve); hls.on(Hls.Events.MEDIA_ATTACHED, resolve);
hls.attachMedia(videoEl); hls.attachMedia(videoEl);
@ -123,9 +125,14 @@ class MoreInfoCamera extends UpdatingElement {
} }
private _teardownPlayback(): any { private _teardownPlayback(): any {
if (this._hlsPolyfillInstance) {
this._hlsPolyfillInstance.destroy();
this._hlsPolyfillInstance = undefined;
}
while (this.lastChild) { while (this.lastChild) {
this.removeChild(this.lastChild); this.removeChild(this.lastChild);
} }
this.stateObj = undefined;
} }
} }