Using built-in hls player if it exists

This commit is contained in:
Zoe Roux 2021-01-05 21:10:53 +01:00
parent 129eb4b9ba
commit c037f0dc72

View File

@ -346,11 +346,12 @@ export class PlayerComponent implements OnInit, OnDestroy, AfterViewInit
selectPlayMethod(playMethod: method) selectPlayMethod(playMethod: method)
{ {
this.playMethod = playMethod; this.playMethod = playMethod;
if (this.playMethod == method.direct) const url: string = `/video/${this.playMethod.toLowerCase()}/${this.item.slug}/`;
this.player.src = `/video/${this.item.slug}`; if (this.playMethod == method.direct || this.player.canPlayType("application/vnd.apple.mpegurl"))
this.player.src = url;
else else
{ {
this.hlsPlayer.loadSource(`/video/${this.playMethod.toLowerCase()}/${this.item.slug}/`); this.hlsPlayer.loadSource(url);
this.hlsPlayer.attachMedia(this.player); this.hlsPlayer.attachMedia(this.player);
this.hlsPlayer.on(Hls.Events.MANIFEST_LOADED, () => this.hlsPlayer.on(Hls.Events.MANIFEST_LOADED, () =>
{ {