From the course: JavaScript: Events
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Starting a new song - JavaScript Tutorial
From the course: JavaScript: Events
Starting a new song
So our media jukebox is working pretty well, but we still have a couple of problems. Especially they happen when you try to play a song after a song has already been playing. So if we play this song right here, (SOUND) and try to play another song, you can see that this one looks like it's still playing. And now this one appears to be paused. (SOUND) Things aren't just working the way that we want them to. Let's go ahead and refresh this. And I'm going to show you how to fix that. So, the problem is, we need to find the song that's playing and take a look at whether or not that song is the same as the song that we're going to click on next. So if you remember, when we click on a song, so let's click on this one. (MUSIC) So the audio player appears, and that song has an ID that is playing. The audio that's playing also has a source attribute. And if you look at the list items they also have a source attribute. So, the way we can tell whether or not the song were clicked on, is the same…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.