diff --git a/assets/js/player.js b/assets/js/player.js index d978d9cf..6a99c3b8 100644 --- a/assets/js/player.js +++ b/assets/js/player.js @@ -1,6 +1,7 @@ 'use strict'; var player_data = JSON.parse(document.getElementById('player_data').textContent); var video_data = JSON.parse(document.getElementById('video_data').textContent); +const CONFIG = JSON.parse(document.getElementById('config').textContent); var options = { liveui: true, @@ -54,8 +55,13 @@ videojs.Vhs.xhr.beforeRequest = function(options) { return options; }; -videojs.Vhs.GOAL_BUFFER_LENGTH = 40; -videojs.Vhs.MAX_GOAL_BUFFER_LENGTH = 80; +// Buffer limits +if (CONFIG.videojs.goal_buffer_length) { + videojs.Vhs.GOAL_BUFFER_LENGTH = CONFIG.videojs.goal_buffer_length; +} +if (CONFIG.videojs.max_goal_buffer_length) { + videojs.Vhs.MAX_GOAL_BUFFER_LENGTH = CONFIG.videojs.max_goal_buffer_length; +} var player = videojs('player', options); diff --git a/config/config.example.yml b/config/config.example.yml index 2b7737b2..c63fe7ec 100644 --- a/config/config.example.yml +++ b/config/config.example.yml @@ -1245,4 +1245,25 @@ video_cache: ## Accepted values: a string ## Default: "Backend" ## -#backend_name_prefix: "Backend" \ No newline at end of file +#backend_name_prefix: "Backend" + +######################################### +# +# VideoJS Settings +# +######################################### + +videojs: + ## Change goal buffer length + ## + ## Accepted values: a positive integer OR null + ## Default: 30 + ## + goal_buffer_length: 30 + + ## Change max goal buffer length + ## + ## Accepted values: a positive integer OR null + ## Default: 60 + ## + max_goal_buffer_length: 60 \ No newline at end of file diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 5dd37968..cdc18c63 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -252,6 +252,16 @@ class Config property backend_name_prefix : String = "Backend" + property videojs : VideoJSConfig = VideoJSConfig.from_yaml("") + + struct VideoJSConfig + include YAML::Serializable + include JSON::Serializable + + property goal_buffer_length : Int32? = 30 + property max_goal_buffer_length : Int32? = 60 + end + def disabled?(option) case disabled = CONFIG.disable_proxy when Bool diff --git a/src/invidious/views/embed.ecr b/src/invidious/views/embed.ecr index 7b7ac7c5..11e2bfe3 100644 --- a/src/invidious/views/embed.ecr +++ b/src/invidious/views/embed.ecr @@ -30,6 +30,13 @@ }.to_pretty_json %> + <%= rendered "components/player" %> diff --git a/src/invidious/views/watch.ecr b/src/invidious/views/watch.ecr index 9c0e5f15..a468a56f 100644 --- a/src/invidious/views/watch.ecr +++ b/src/invidious/views/watch.ecr @@ -82,6 +82,13 @@ we're going to need to do it here in order to allow for translations. }.to_pretty_json %> +