Play is this one track and we don’t want that we want this to be dynamic so that.
We can have multiple songs where we can just scroll through and play them alright so what we’re gonna do is we need to create a new function.
Alright so I’m gonna create function called init audio alright so this is basically going to control the audio object so we.
Want to I’m just gonna grab this here and I’m gonna have that initialize inside of the init audio function and this is also where we’re gonna get the dynamic content because right now for instance the song and the.
Artist we just put those in the HTML alright we put them right here and I’m actually going to get rid of.
These so I’ll get rid of this that duration is fine yeah duration is fine because it changes when we play the song so we can leave the zeroes the cover that’s another thing we have to get.
Rid of because that’s going to be generated according to which song is playing all right so that should do it now it’s gonna look a little different you can see our covers gone our song info’ so that’s all going to be initialized in the init audio function alright so let’s go to that and I want to set some variables up top okay and I set a variable called song.
And basically actually this init audio we’re gonna pass in element okay and the elements basically going to be the list item of the so current song okay so we want variable song is going to be equal to element.
Dots attribute and we want that to be the song attribute okay so if we go to our HTML you can see at.
The bottom every song we have has a song attribute so that’s where it’s going to get the actual mp3 file name okay and it’s going to put that in there for us.
Alright so the next variable that I want is gonna be the title okay so variable title is going to be equal to element dot text okay so the text method is basically just going to grab whatever we have inside of the list item or the element which would be for instance this okay and you don’t have to.
You could just have the song name you might want to put the artist in the song whatever you’d like is fine okay so that’s the title now we want the cover okay so we’ll create.
A variable called cover and gonna set that equal to element dot attribute and we want to grab the cover attribute or the value for the cover attribute you can see we have it here okay so if you want to put more songs.
Here and change the name of the album cover to a valid image file it’ll change when you change the song all right the less variable I.
Want to create up here is the artist variable and that’s going to be equal to elements dot artist I’m sorry element dot attribute and then hardest okay so there’s our variables we’re going to create a new object here create audio object.
Alright now instead of passing in this static link to this song what we’re gonna do is pass in media which is.