mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-26 09:58:14 +01:00
[IN TESTING] attempt to fix #106
This commit is contained in:
parent
8054805054
commit
0b48788174
1 changed files with 40 additions and 0 deletions
|
@ -982,6 +982,46 @@ function cstsRemaining(totalTimeInSeconds, elapsedTimeInSeconds) {
|
||||||
aud.addEventListener("canplaythrough", shouldPlay);
|
aud.addEventListener("canplaythrough", shouldPlay);
|
||||||
vid.addEventListener("canplaythrough", shouldPlay);
|
vid.addEventListener("canplaythrough", shouldPlay);
|
||||||
})
|
})
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||||
|
const source = audioContext.createMediaElementSource(aud);
|
||||||
|
const analyser = audioContext.createAnalyser();
|
||||||
|
|
||||||
|
source.connect(analyser);
|
||||||
|
analyser.connect(audioContext.destination);
|
||||||
|
|
||||||
|
function getQueryParam(name) {
|
||||||
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
|
return urlParams.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check the quality parameter
|
||||||
|
const quality = getQueryParam('qua');
|
||||||
|
|
||||||
|
// Function to check if audio is playing
|
||||||
|
function checkAudio() {
|
||||||
|
if (video.ended || video.paused || quality === 'medium') return;
|
||||||
|
|
||||||
|
// Check if the audio volume is greater than 0
|
||||||
|
if (aud.volume === 0) return;
|
||||||
|
|
||||||
|
const bufferLength = analyser.fftSize;
|
||||||
|
const dataArray = new Uint8Array(bufferLength);
|
||||||
|
analyser.getByteFrequencyData(dataArray);
|
||||||
|
|
||||||
|
// Check if there's any significant audio data
|
||||||
|
const isAudioPlaying = dataArray.some(value => value > 0);
|
||||||
|
|
||||||
|
if (!isAudioPlaying) {
|
||||||
|
// Play/pause workaround to reset audio
|
||||||
|
aud.pause();
|
||||||
|
aud.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check audio every second
|
||||||
|
setInterval(checkAudio, 1000);
|
||||||
</script>
|
</script>
|
||||||
<% if(shortsui) { %>
|
<% if(shortsui) { %>
|
||||||
<script>
|
<script>
|
||||||
|
|
Loading…
Reference in a new issue