From: Chocobozzz Date: Tue, 14 May 2019 09:35:54 +0000 (+0200) Subject: Use HLS by default if enabled X-Git-Tag: v1.3.0-rc.1~2 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=656591660527e8ba48d496c8d6b34598f869ea05;p=oweals%2Fpeertube.git Use HLS by default if enabled --- 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()