From 2e3681c36edb9e95509d510ab445ab3d95bb4328 Mon Sep 17 00:00:00 2001 From: 4gray Date: Sun, 17 Jan 2021 23:37:50 +0100 Subject: [PATCH] perf: destroy hls instance after view change --- .../html-video-player/html-video-player.component.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/player/components/html-video-player/html-video-player.component.ts b/src/app/player/components/html-video-player/html-video-player.component.ts index 15b96433d..af6727522 100644 --- a/src/app/player/components/html-video-player/html-video-player.component.ts +++ b/src/app/player/components/html-video-player/html-video-player.component.ts @@ -3,6 +3,7 @@ import { ElementRef, Input, OnChanges, + OnDestroy, SimpleChanges, ViewChild, } from '@angular/core'; @@ -14,7 +15,7 @@ import * as Hls from 'hls.js'; templateUrl: './html-video-player.component.html', styleUrls: ['./html-video-player.component.scss'], }) -export class HtmlVideoPlayerComponent implements OnChanges { +export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy { /** Channel to play */ @Input() channel: Channel; @@ -58,4 +59,11 @@ export class HtmlVideoPlayerComponent implements OnChanges { ); } } + + /** + * Destroy hls instance on component destroy + */ + ngOnDestroy(): void { + this.hls.destroy(); + } }