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.
This commit is contained in:
Thomas Lange 2023-09-26 21:45:52 +02:00
parent bb14f79496
commit bf470704a5
10 changed files with 41 additions and 2 deletions

View file

@ -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;