From 96cd35be4d14c922e749c8f6a2aad1d5aa9ed609 Mon Sep 17 00:00:00 2001 From: 4gray <4gray@users.noreply.github.com> Date: Fri, 24 Feb 2023 13:45:57 +0100 Subject: [PATCH] refactor: improve error handling --- .../html-video-player.component.ts | 20 ++++++++++--------- .../video-player/video-player.component.ts | 2 +- 2 files changed, 12 insertions(+), 10 deletions(-) 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 199ca965b..cef1bdc45 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 @@ -48,15 +48,17 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy { */ playChannel(channel: Channel): void { if (this.hls) this.hls.destroy(); - const url = channel.url + channel.epgParams; - if (Hls && Hls.isSupported()) { - console.log('... switching channel to ', channel.name, url); - this.hls = new Hls(); - this.hls.attachMedia(this.videoPlayer.nativeElement); - this.hls.loadSource(url); - this.handlePlayOperation(); - } else { - console.error('something wrong with hls.js init...'); + if (channel.url) { + const url = channel.url + channel.epgParams; + if (Hls && Hls.isSupported()) { + console.log('... switching channel to ', channel.name, url); + this.hls = new Hls(); + this.hls.attachMedia(this.videoPlayer.nativeElement); + this.hls.loadSource(url); + this.handlePlayOperation(); + } else { + console.error('something wrong with hls.js init...'); + } } } diff --git a/src/app/player/components/video-player/video-player.component.ts b/src/app/player/components/video-player/video-player.component.ts index 3a9b35c63..140b6b781 100644 --- a/src/app/player/components/video-player/video-player.component.ts +++ b/src/app/player/components/video-player/video-player.component.ts @@ -52,7 +52,7 @@ export class VideoPlayerComponent implements OnInit, OnDestroy { /** Active selected channel */ activeChannel$ = this.store .select(selectActive) - .pipe(filter((channel) => Boolean(channel))); + .pipe(filter((channel) => Boolean(channel?.url))); /** Channels list */ channels$!: Observable;