Skip to content

Commit

Permalink
fix(player): add source for each song play
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaraa committed Jul 2, 2024
1 parent a24956b commit 2b9d4b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app/static/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,8 +615,13 @@ async function playSong(song) {

await downloadSong(song.yt_id).then(() => {
stopMuzikk();
audioPlayerEl.children.item(0).src =
`${location.protocol}//${location.host}/muzikkx/${song.yt_id}.mp3`;
// audioPlayerEl.children.item(0).src =
if (audioPlayerEl.childNodes.length > 0) {
audioPlayerEl.removeChild(audioPlayerEl.childNodes.item(0));
}
const src = document.createElement("source");
src.src = `${location.protocol}//${location.host}/muzikkx/${song.yt_id}.mp3`;
audioPlayerEl.appendChild(src);
audioPlayerEl.load();
});

Expand Down
4 changes: 1 addition & 3 deletions app/views/components/player/player.templ
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ templ PlayerSticky() {
id="audio-player"
controls
preload="none"
>
<source/>
</audio>
></audio>
///
<style>
.collapsed {
Expand Down

0 comments on commit 2b9d4b3

Please sign in to comment.