mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-10 10:06:15 -08:00
1 file changed
+17
-2
@@ -46,7 +46,7 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
|
|||||||
console.log('... switching channel to ', channel.name, url);
|
console.log('... switching channel to ', channel.name, url);
|
||||||
this.hls.loadSource(url);
|
this.hls.loadSource(url);
|
||||||
this.hls.attachMedia(this.videoPlayer.nativeElement);
|
this.hls.attachMedia(this.videoPlayer.nativeElement);
|
||||||
this.videoPlayer.nativeElement.play();
|
this.handlePlayOperation();
|
||||||
} else if (
|
} else if (
|
||||||
this.videoPlayer.nativeElement.canPlayType(
|
this.videoPlayer.nativeElement.canPlayType(
|
||||||
'application/vnd.apple.mpegurl'
|
'application/vnd.apple.mpegurl'
|
||||||
@@ -56,12 +56,27 @@ export class HtmlVideoPlayerComponent implements OnChanges, OnDestroy {
|
|||||||
this.videoPlayer.nativeElement.addEventListener(
|
this.videoPlayer.nativeElement.addEventListener(
|
||||||
'loadedmetadata',
|
'loadedmetadata',
|
||||||
() => {
|
() => {
|
||||||
this.videoPlayer.nativeElement.play();
|
this.handlePlayOperation();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles promise based play operation
|
||||||
|
*/
|
||||||
|
handlePlayOperation(): void {
|
||||||
|
const playPromise = this.videoPlayer.nativeElement.play();
|
||||||
|
|
||||||
|
if (playPromise !== undefined) {
|
||||||
|
playPromise
|
||||||
|
.then(() => {
|
||||||
|
// Automatic playback started!
|
||||||
|
})
|
||||||
|
.catch((error) => console.error(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy hls instance on component destroy
|
* Destroy hls instance on component destroy
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in new issue
Block a user