-
-
Save monokaijs/1daac12ffb2c0b5cff3584fa6a41f20c to your computer and use it in GitHub Desktop.
A URL-based graphic eq (demo: https://www.facebook.com/J2TEAM.ManhTuan/videos/1346181608854508/) - Modified by @monokaijs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="author" content="Jake Albaugh"> | |
<title>JUNO_OKYO</title> | |
<!-- Modified by @MonokaiJs --> | |
</head> | |
<body> | |
<!-- Simple audio playback --> | |
<audio src="cam.mp3" controls> | |
Your browser does not support the <code>audio</code> element. | |
</audio> | |
<video src="https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_5mb.mp4" controls> | |
Your browser does not support the <code>video</code> element. | |
</video> | |
<script> | |
const medias = document.querySelectorAll('audio,video'); | |
medias.forEach(media => {media.onplay = start}); | |
let l, x, a, d; | |
function start(e) { | |
l = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█']; | |
x = new AudioContext(); | |
a = x.createAnalyser(); | |
a.fftSize = 32; | |
d = new Uint8Array(16); | |
navigator.mediaDevices.getUserMedia({ | |
audio: true | |
}).then(s => { | |
x.createMediaStreamSource(s).connect(a); | |
z(); | |
}); | |
} | |
function z() { | |
setTimeout(z, 40); | |
a.getByteFrequencyData(d); | |
let s = []; | |
d.forEach(v => s.push(l[Math.floor((v / 255) * 8)])); | |
location.hash = document.title = s.join(''); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment