fix: load audio source

This commit is contained in:
relikd
2024-07-22 20:30:55 +02:00
parent e1e3c43cca
commit 880c7a9bfa
2 changed files with 7 additions and 2 deletions

View File

@@ -61,7 +61,13 @@ function setBadge(div, category) {
function loadAudio(detailDiv, srcUrl) {
const x = detailDiv.querySelector('audio');
x.hidden = !srcUrl;
x.querySelector('source').src = srcUrl || '';
x.querySelectorAll('source').forEach(x => x.remove());
if (srcUrl) {
const audioSrc = document.createElement('source');
audioSrc.src = srcUrl;
audioSrc.type = 'audio/mpeg';
x.appendChild(audioSrc);
}
x.load(); // stops playing and reloads source
}