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:
@@ -5,7 +5,8 @@ let currentAudio;
|
|||||||
let volume = 1;
|
let volume = 1;
|
||||||
|
|
||||||
function playAudio() {
|
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 = () => {
|
currentAudio.onplay = () => {
|
||||||
isPlaying = true;
|
isPlaying = true;
|
||||||
playBtn.innerText = "pause";
|
playBtn.innerText = "pause";
|
||||||
|
Reference in New Issue
Block a user