Skip to content

Commit

Permalink
fix(player): add delay for just safari
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaraa committed Jul 4, 2024
1 parent 9beff28 commit 19ed361
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions app/static/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,9 +621,14 @@ async function playSong(song) {
}
const src = document.createElement("source");
src.src = `${location.protocol}//${location.host}/muzikkx/${song.yt_id}.mp3`;
src.target = "audio/mpeg";
src.type = "audio/mpeg";
audioPlayerEl.appendChild(src);

if (isSafari()) {
setTimeout(80);
}
audioPlayerEl.load();

// song's details setting, yada yada
{
if (song.title) {
Expand Down Expand Up @@ -664,12 +669,6 @@ async function playSong(song) {
songImageExpandedEl.innerHTML = "";
}
}
{
setTimeout(75);
audioPlayerEl.load();
setTimeout(75);
audioPlayerEl.load();
}
setMediaSessionMetadata(song);
playMuzikk();
await updateSongPlays();
Expand Down Expand Up @@ -908,6 +907,10 @@ function setMediaSessionMetadata(song) {
});
}

function isSafari() {
return navigator.userAgent.toLowerCase().includes("safari");
}

const [toggleLoop, handleLoop, checkLoop] = looper();
const [playMuzikk, pauseMuzikk, togglePP] = playPauser(audioPlayerEl);
const stopMuzikk = stopper(audioPlayerEl);
Expand Down

0 comments on commit 19ed361

Please sign in to comment.