refactor: improve error handling

This commit is contained in:
4gray committed 2023-02-24 13:45:57 +01:00
1 parent 2130fe309d
commit 96cd35be4d
2 files changed
+12 -10

No files matched your search

@@ -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...');
}
}
}
@@ -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<Channel[]>;