From 5a71acd2547c098657ae6e0e31e0862094585088 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 21 Nov 2019 17:01:24 +0100 Subject: [PATCH] Disable webtorrent support in client --- .../edit-custom-config.component.html | 21 ++++++++++++++++++- .../edit-custom-config.component.ts | 3 +++ client/src/app/core/server/server.service.ts | 3 +++ .../modals/video-download.component.html | 2 +- .../video/modals/video-download.component.ts | 10 +++++++-- .../app/shared/video/video-details.model.ts | 4 ++++ .../+video-edit/video-update.component.ts | 2 +- .../+video-watch/video-watch.component.html | 4 ++-- .../+video-watch/video-watch.component.ts | 2 +- client/src/standalone/videos/embed.ts | 2 +- 10 files changed, 44 insertions(+), 9 deletions(-) diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html index e057e394e..82f467e16 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html @@ -491,6 +491,23 @@ + +
+ + + + Experimental, we suggest you to not disable webtorrent support for now + +

If you also enabled HLS support, it will multiply videos storage by 2

+
+
+
+
+
+
- Requires ffmpeg >= 4.1 and multiplies videos storage by 2! + Requires ffmpeg >= 4.1

Generate HLS playlists and fragmented MP4 files resulting in a better playback than with the current default player:

    @@ -507,6 +524,8 @@
  • Faster playback in particular with long videos
  • More stable playback (less bugs/infinite loading)
+ +

If you also enabled WebTorrent support, it will multiply videos storage by 2

diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts index f3fb849bb..8411c4f4f 100644 --- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts +++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts @@ -169,6 +169,9 @@ export class EditCustomConfigComponent extends FormReactive implements OnInit { resolutions: {}, hls: { enabled: null + }, + webtorrent: { + enabled: null } }, autoBlacklist: { diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts index 7fb95fe4e..8e76bebb1 100644 --- a/client/src/app/core/server/server.service.ts +++ b/client/src/app/core/server/server.service.ts @@ -65,6 +65,9 @@ export class ServerService { enabledResolutions: [], hls: { enabled: false + }, + webtorrent: { + enabled: true } }, avatar: { diff --git a/client/src/app/shared/video/modals/video-download.component.html b/client/src/app/shared/video/modals/video-download.component.html index 935d01330..3619f24e5 100644 --- a/client/src/app/shared/video/modals/video-download.component.html +++ b/client/src/app/shared/video/modals/video-download.component.html @@ -9,7 +9,7 @@
diff --git a/client/src/app/shared/video/modals/video-download.component.ts b/client/src/app/shared/video/modals/video-download.component.ts index 4022a11e8..0e9e44de7 100644 --- a/client/src/app/shared/video/modals/video-download.component.ts +++ b/client/src/app/shared/video/modals/video-download.component.ts @@ -24,12 +24,18 @@ export class VideoDownloadComponent { private i18n: I18n ) { } + getVideoFiles () { + if (!this.video) return [] + + return this.video.getFiles() + } + show (video: VideoDetails) { this.video = video this.activeModal = this.modalService.open(this.modal) - this.resolutionId = this.video.files[0].resolution.id + this.resolutionId = this.getVideoFiles()[0].resolution.id } onClose () { @@ -45,7 +51,7 @@ export class VideoDownloadComponent { // HTML select send us a string, so convert it to a number this.resolutionId = parseInt(this.resolutionId.toString(), 10) - const file = this.video.files.find(f => f.resolution.id === this.resolutionId) + const file = this.getVideoFiles().find(f => f.resolution.id === this.resolutionId) if (!file) { console.error('Could not find file with resolution %d.', this.resolutionId) return diff --git a/client/src/app/shared/video/video-details.model.ts b/client/src/app/shared/video/video-details.model.ts index e4d443a06..c2a85d8e8 100644 --- a/client/src/app/shared/video/video-details.model.ts +++ b/client/src/app/shared/video/video-details.model.ts @@ -55,4 +55,8 @@ export class VideoDetails extends Video implements VideoDetailsServerModel { hasHlsPlaylist () { return !!this.getHlsPlaylist() } + + getFiles () { + if (this.files.length === 0) return this.getHlsPlaylist().files + } } diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index 81c66ff20..6ec187f40 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -56,7 +56,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE - const videoFiles = (video as VideoDetails).files + const videoFiles = (video as VideoDetails).getFiles() if (videoFiles.length > 1) { // Already transcoded this.waitTranscodingEnabled = false } diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index ac474b427..5b98a7bd4 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html @@ -221,7 +221,7 @@
- + - +
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 af4afd456..c78f5b9a2 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -469,7 +469,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { segmentsSha256Url: hlsPlaylist.segmentsSha256Url, redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl), trackerAnnounce: this.video.trackerUrls, - videoFiles: this.video.files + videoFiles: hlsPlaylist.files } as P2PMediaLoaderOptions Object.assign(options, { p2pMediaLoader }) diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index 19d2a1d02..896d90de2 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -207,7 +207,7 @@ export class PeerTubeEmbed { segmentsSha256Url: hlsPlaylist.segmentsSha256Url, redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl), trackerAnnounce: videoInfo.trackerUrls, - videoFiles: videoInfo.files + videoFiles: hlsPlaylist.files } as P2PMediaLoaderOptions }) } -- 2.41.0