From 43c66a91dfe5b8e101047b815ab2da8512a00904 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 29 Nov 2019 14:10:24 +0100 Subject: Add ability to disable P2P in HLS player too --- .../my-account-video-settings.component.html | 2 +- client/src/assets/player/peertube-player-local-storage.ts | 4 ++-- client/src/assets/player/peertube-player-manager.ts | 4 +++- client/src/assets/player/webtorrent/webtorrent-plugin.ts | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) (limited to 'client/src') diff --git a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html index 6f9159ec8..17d8cde06 100644 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html @@ -38,7 +38,7 @@
diff --git a/client/src/assets/player/peertube-player-local-storage.ts b/client/src/assets/player/peertube-player-local-storage.ts index f6c5c5419..75ccfe618 100644 --- a/client/src/assets/player/peertube-player-local-storage.ts +++ b/client/src/assets/player/peertube-player-local-storage.ts @@ -10,7 +10,7 @@ function getStoredVolume () { return undefined } -function getStoredWebTorrentEnabled (): boolean { +function getStoredP2PEnabled (): boolean { const value = getLocalStorage('webtorrent_enabled') if (value !== null && value !== undefined) return value === 'true' @@ -72,7 +72,7 @@ function getStoredLastSubtitle () { export { getStoredVolume, - getStoredWebTorrentEnabled, + getStoredP2PEnabled, getStoredMute, getStoredTheater, saveVolumeInStore, diff --git a/client/src/assets/player/peertube-player-manager.ts b/client/src/assets/player/peertube-player-manager.ts index bda718cff..7c7c9ad2a 100644 --- a/client/src/assets/player/peertube-player-manager.ts +++ b/client/src/assets/player/peertube-player-manager.ts @@ -18,6 +18,7 @@ import { getCompleteLocale, getShortLocale, is18nLocale, isDefaultLocale } from import { segmentValidatorFactory } from './p2p-media-loader/segment-validator' import { segmentUrlBuilderFactory } from './p2p-media-loader/segment-url-builder' import { RedundancyUrlManager } from './p2p-media-loader/redundancy-url-manager' +import { getStoredP2PEnabled } from './peertube-player-local-storage' // Change 'Playback Rate' to 'Speed' (smaller for our settings menu) videojsUntyped.getComponent('PlaybackRateMenuButton').prototype.controlText_ = 'Speed' @@ -245,7 +246,8 @@ export class PeertubePlayerManager { segmentValidator: segmentValidatorFactory(options.p2pMediaLoader.segmentsSha256Url), rtcConfig: getRtcConfig(), requiredSegmentsPriority: 5, - segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager) + segmentUrlBuilder: segmentUrlBuilderFactory(redundancyUrlManager), + useP2P: getStoredP2PEnabled() }, segments: { swarmId: p2pMediaLoaderOptions.playlistUrl diff --git a/client/src/assets/player/webtorrent/webtorrent-plugin.ts b/client/src/assets/player/webtorrent/webtorrent-plugin.ts index 656a32f49..5101b5162 100644 --- a/client/src/assets/player/webtorrent/webtorrent-plugin.ts +++ b/client/src/assets/player/webtorrent/webtorrent-plugin.ts @@ -11,7 +11,7 @@ import { getAverageBandwidthInStore, getStoredMute, getStoredVolume, - getStoredWebTorrentEnabled, + getStoredP2PEnabled, saveAverageBandwidth } from '../peertube-player-local-storage' import { VideoFile } from '@shared/models' @@ -77,7 +77,7 @@ class WebTorrentPlugin extends Plugin { // Disable auto play on iOS this.autoplay = options.autoplay && this.isIOS() === false - this.playerRefusedP2P = !getStoredWebTorrentEnabled() + this.playerRefusedP2P = !getStoredP2PEnabled() this.videoFiles = options.videoFiles this.videoDuration = options.videoDuration -- cgit v1.2.3