neddit

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

commit
49e3bd78770339a1b29358245b20f36c3885aa5f
parent
274189bc8a423c478feca236412f2ed8e6bade7e
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-07-24 22:00
video audio

-	might get out of sync (could use timeupdate event)
-	cannot control mute/volume

Diffstat

M static/video.js 24 ++++++++++++++++++++++++

1 files changed, 24 insertions, 0 deletions


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

@@ -24,4 +24,28 @@
   24    24 			}
   25    25 		});
   26    26 	}, 100), {passive: true});
   -1    27 
   -1    28 	document.querySelectorAll('video').forEach(function(video) {
   -1    29 		var url = video.querySelectorAll('source')[3].src;
   -1    30 		var audio = document.createElement('audio');
   -1    31 		audio.src = url.replace('DASH_96', 'DASH_audio');
   -1    32 		audio.preload = 'none';
   -1    33 		audio.loop = true;
   -1    34 		video.after(audio);
   -1    35 
   -1    36 		var sync = function() {
   -1    37 			audio.currentTime = video.currentTime;
   -1    38 		}
   -1    39 		video.onplay = function() {
   -1    40 			sync();
   -1    41 			audio.play();
   -1    42 		};
   -1    43 		video.onpause = function() {
   -1    44 			audio.pause();
   -1    45 		};
   -1    46 		video.onseeked = sync;
   -1    47 		video.onvolumechange = function() {
   -1    48 			audio.volume = video.volume;
   -1    49 		};
   -1    50 	});
   27    51 })();