neddit

the frontend of the frontpage of the internet  https://neddit.ce9e.org
git clone https://git.ce9e.org/neddit.git

commit
969d40d47b5e30659e643aca333a3180e39c9ffa
parent
f7ba85fb9d4bd2a586327a45cf7dba4a560cb181
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-10-03 05:48
fixup e922d9f: support different audio sources

not all videos use the same filename

Diffstat

M static/video.js 9 ++++++++-

1 files changed, 8 insertions, 1 deletions


diff --git a/static/video.js b/static/video.js

@@ -12,6 +12,12 @@ var thottle = function(fn, timeout) {
   12    12 	};
   13    13 };
   14    14 
   -1    15 var addSource = function(audio, url) {
   -1    16 	var source = document.createElement('source');
   -1    17 	source.src = url;
   -1    18 	audio.append(source);
   -1    19 };
   -1    20 
   15    21 window.addEventListener('scroll', thottle(function() {
   16    22 	document.querySelectorAll('video').forEach(function(video) {
   17    23 		if (video.paused) {
@@ -31,7 +37,8 @@ document.querySelectorAll('video').forEach(function(video) {
   31    37 
   32    38 	var url = video.querySelectorAll('source')[4].src;
   33    39 	var audio = document.createElement('audio');
   34    -1 	audio.src = url.replace('DASH_96', 'DASH_AUDIO_64');
   -1    40 	addSource(audio, url.replace('DASH_96', 'DASH_AUDIO_64'));
   -1    41 	addSource(audio, url.replace('DASH_96', 'DASH_audio'));
   35    42 	audio.preload = 'none';
   36    43 	audio.loop = true;
   37    44 	video.after(audio);