fix: prevent browser from caching audio

Add a random query parameter to the end of the track URL to prevent the
browser from caching the audio file, forcing it to fetch the latest
track
This commit is contained in:
2024-07-20 21:48:43 +01:00
parent ae37327095
commit 66a873b3c2

View File

@@ -5,7 +5,8 @@ let currentAudio;
let volume = 1;
function playAudio() {
currentAudio = new Audio("/current.mp3");
// add a random query parameter at the end to prevent browser caching
currentAudio = new Audio(`/current.mp3?t=${Date.now()}`);
currentAudio.onplay = () => {
isPlaying = true;
playBtn.innerText = "pause";