From 656591660527e8ba48d496c8d6b34598f869ea05 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 14 May 2019 11:35:54 +0200 Subject: [PATCH] Use HLS by default if enabled --- client/src/app/shared/video/video-details.model.ts | 4 ++++ .../app/videos/+video-watch/video-watch.component.ts | 10 +++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts index 8463e15d7..22f024656 100644 --- a/client/src/app/shared/video/video-details.model.ts +++ b/client/src/app/shared/video/video-details.model.ts @@ -52,4 +52,8 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { getHlsPlaylist () { return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS) } + + hasHlsPlaylist () { + return !!this.getHlsPlaylist() + } } diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 0532e7de7..b147b75b0 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -423,7 +423,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } } - const mode: PlayerMode = urlOptions.playerMode === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent' + let mode: PlayerMode + + if (urlOptions.playerMode) { + if (urlOptions.playerMode === 'p2p-media-loader') mode = 'p2p-media-loader' + else mode = 'webtorrent' + } else { + if (this.video.hasHlsPlaylist()) mode = 'p2p-media-loader' + else mode = 'webtorrent' + } if (mode === 'p2p-media-loader') { const hlsPlaylist = this.video.getHlsPlaylist() -- 2.25.1