From bf470704a5a3071cebb1d558efaef8542a16dde6 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Tue, 26 Sep 2023 21:45:52 +0200 Subject: [PATCH 1/3] Add option to control preloading of video data Fix #4110 by adding an option to control the preloading of video data on page load. If disabled ("false"), the browser will not preload any video data until the user explicitly hits the "Play" button. If enabled ("true"), the default behavior will be used, which means the browser decides how much of the video will be preloaded. --- assets/js/player.js | 5 ++++- config/config.example.yml | 14 ++++++++++++++ locales/de.json | 1 + locales/en-US.json | 1 + src/invidious/config.cr | 1 + src/invidious/routes/preferences.cr | 5 +++++ src/invidious/user/preferences.cr | 1 + src/invidious/videos/video_preferences.cr | 6 ++++++ src/invidious/views/components/player.ecr | 4 +++- src/invidious/views/user/preferences.ecr | 5 +++++ 10 files changed, 41 insertions(+), 2 deletions(-) diff --git a/assets/js/player.js b/assets/js/player.js index bb53ac24d..398c66f8e 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -3,7 +3,6 @@ var player_data = JSON.parse(document.getElementById('player_data').textContent) var video_data = JSON.parse(document.getElementById('video_data').textContent); var options = { - preload: 'auto', liveui: true, playbackRates: [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0], controlBar: { @@ -35,6 +34,10 @@ if (player_data.aspect_ratio) { options.aspectRatio = player_data.aspect_ratio; } +if (player_data.preload) { + options.preload = player_data.preload +} + var embed_url = new URL(location); embed_url.searchParams.delete('v'); var short_url = location.origin + '/' + video_data.id + embed_url.search; diff --git a/config/config.example.yml b/config/config.example.yml index b44fcc0e0..b1a76edf9 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -718,6 +718,20 @@ default_user_preferences: # Video player behavior # ----------------------------- + ## + ## Automatically preload video on page load. This option controls the + ## value for the "preload" attribute of the HTML5