Updated so that the player can use multiple sources

This commit is contained in:
Anon 2024-09-18 22:37:32 -07:00
parent 0a239f5255
commit 885f1e69ea
2 changed files with 61 additions and 11 deletions

View File

@ -56,6 +56,7 @@ function audioPlayer()
{ {
if (idx === currentSong) if (idx === currentSong)
{ {
aPlay.load()
aPlay.play() aPlay.play()
return return
} }
@ -66,12 +67,21 @@ function audioPlayer()
currentSong = wrap(idx, aListLinks.length) currentSong = wrap(idx, aListLinks.length)
aListLinks[currentSong].classList.add("current-song"); aListLinks[currentSong].classList.add("current-song");
aPlay.src = musicList[currentSong][3] aPlay.querySelectorAll("source").forEach(source => source.remove())
const sources = musicList[currentSong][3]
sources.forEach(source => {
const newSource = document.createElement("source")
newSource.src = source.src
newSource.type = source.type
aPlay.appendChild(newSource)
})
// aPlay.src = musicList[currentSong][3]
aTrack.innerHTML = musicList[currentSong][0] aTrack.innerHTML = musicList[currentSong][0]
aArtist.innerHTML = musicList[currentSong][1] aArtist.innerHTML = musicList[currentSong][1]
aCoverArt.src = musicList[currentSong][4] aCoverArt.src = musicList[currentSong][4]
if (doplay === true) if (doplay === true)
{ {
aPlay.load()
aPlay.play() aPlay.play()
} }
} }

View File

@ -27,61 +27,101 @@ const musicList = [
[ "Declare War on All Vocaloid", [ "Declare War on All Vocaloid",
"Sukone Tei", "Sukone Tei",
"05:53", "05:53",
"media/declare_war_on_all_vocaloid.opus", [
{src: "media/declare_war_on_all_vocaloid.ogg", type: "audio/ogg"},
{src: "media/declare_war_on_all_vocaloid.m4a", type: "audio/m4a"},
{src: "media/declare_war_on_all_vocaloid.mp3", type: "audio/mp3"}
],
"art/declare_war_on_all_vocaloid.png" "art/declare_war_on_all_vocaloid.png"
], ],
[ "Chains", [ "Chains",
"Sukone Tei", "Sukone Tei",
"05:46", "05:46",
"media/chains.m4a", [
{src: "media/chains.ogg", type: "audio/ogg"},
{src: "media/chains.m4a", type: "audio/m4a"},
{src: "media/chains.mp3", type: "audio/mp3"}
],
"art/chains.png" "art/chains.png"
], ],
[ "Verheerender - LOYALTY", [ "Verheerender - LOYALTY",
"Azur Lane", "Azur Lane",
"01:45", "01:45",
"media/loyalty.opus", [
{src: "media/loyalty.ogg", type: "audio/ogg"},
{src: "media/loyalty.m4a", type: "audio/m4a"},
{src: "media/loyalty.mp3", type: "audio/mp3"}
],
"art/loyalty.jpg" "art/loyalty.jpg"
], ],
[ "True Love Restraint", [ "True Love Restraint",
"Len Kagamine", "Len Kagamine",
"03:35", "03:35",
"media/true_love_restraint.mp3", [
{src: "media/true_love_restraint.ogg", type: "audio/ogg"},
{src: "media/true_love_restraint.m4a", type: "audio/m4a"},
{src: "media/true_love_restraint.mp3", type: "audio/mp3"}
],
"art/true_love_restraint.jpg" "art/true_love_restraint.jpg"
], ],
[ "Tei", [ "Tei",
"Sukone Tei", "Sukone Tei",
"03:58", "03:58",
"media/tei.opus", [
{src: "media/tei.ogg", type: "audio/ogg"},
{src: "media/tei.m4a", type: "audio/m4a"},
{src: "media/tei.mp3", type: "audio/mp3"}
],
"art/tei.png" "art/tei.png"
], ],
[ "iNSaNiTY", [ "iNSaNiTY",
"Kasane Teto + Namine Ritsu", "Kasane Teto + Namine Ritsu",
"04:55", "04:55",
"media/insanity.mp3", [
{src: "media/insanity.ogg", type: "audio/ogg"},
{src: "media/insanity.m4a", type: "audio/m4a"},
{src: "media/insanity.mp3", type: "audio/mp3"}
],
"art/insanity.png" "art/insanity.png"
], ],
[ "Youre Seriously Mad? Im Not Mistaken Here?", [ "Youre Seriously Mad? Im Not Mistaken Here?",
"MAYU", "MAYU",
"03:50", "03:50",
"media/youre_seriously_mad.flac", [
{src: "media/youre_seriously_mad.ogg", type: "audio/ogg"},
{src: "media/youre_seriously_mad.m4a", type: "audio/m4a"},
{src: "media/youre_seriously_mad.mp3", type: "audio/mp3"}
],
"art/your_seriously_mad.png" "art/your_seriously_mad.png"
], ],
[ "Psychotic Love Song", [ "Psychotic Love Song",
"Sukone Tei", "Sukone Tei",
"05:02", "05:02",
"media/psychotic_love_song.flac", [
{src: "media/psychotic_love_song.ogg", type: "audio/ogg"},
{src: "media/psychotic_love_song.m4a", type: "audio/m4a"},
{src: "media/psychotic_love_song.mp3", type: "audio/mp3"}
],
"art/psychoticlovesong.png" "art/psychoticlovesong.png"
], ],
[ "Rotten Girl, Grotesque Romance", [ "Rotten Girl, Grotesque Romance",
"Hatsune Miku", "Hatsune Miku",
"04:10", "04:10",
"media/rotten_girl.mp3", [
{src: "media/rotten_girl.ogg", type: "audio/ogg"},
{src: "media/rotten_girl.m4a", type: "audio/m4a"},
{src: "media/rotten_girl.mp3", type: "audio/mp3"}
],
"art/grotesquromance.png" "art/grotesquromance.png"
], ],
[ "Monopolizing Romance", [ "Monopolizing Romance",
"Hatsune Miku", "Hatsune Miku",
"03:36", "03:36",
"media/monopolizing_romance.flac", [
{src: "media/monopolizing_romance.ogg", type: "audio/ogg"},
{src: "media/monopolizing_romance.m4a", type: "audio/m4a"},
{src: "media/monopolizing_romance.mp3", type: "audio/mp3"}
],
"art/monopolizing_romance.png" "art/monopolizing_romance.png"
] ]
] ]