Spaces:
Running
Running
Commit
•
ae8f9a8
1
Parent(s):
b45ae19
Update audio.js
Browse files
audio.js
CHANGED
@@ -1,40 +1,40 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
//
|
5 |
-
|
6 |
-
|
7 |
-
//
|
8 |
-
const
|
9 |
-
|
10 |
-
const
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
// Append the new song item to the playlist
|
29 |
-
const playlist = document.querySelector('.song-list');
|
30 |
-
playlist.appendChild(newSongItem);
|
31 |
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
|
39 |
|
40 |
function validateSignup() {
|
|
|
1 |
+
function addToPlaylist() {
|
2 |
+
// Get information about the song
|
3 |
+
const songTitle = document.querySelector('.title').innerText;
|
4 |
+
const artist = 'Singer Name'; // You can replace this with the actual artist name
|
5 |
+
const audioSource = document.querySelector('#audio source').getAttribute('src');
|
6 |
+
|
7 |
+
// Create elements for the new song in the playlist
|
8 |
+
const playlist = document.querySelector('.playlist');
|
9 |
+
|
10 |
+
const newSongDiv = document.createElement('div');
|
11 |
+
newSongDiv.classList.add('song1');
|
12 |
+
|
13 |
+
const newSongTitle = document.createElement('h3');
|
14 |
+
newSongTitle.textContent = songTitle;
|
15 |
+
|
16 |
+
const newArtist = document.createElement('p');
|
17 |
+
newArtist.textContent = `Artist: ${artist}`;
|
18 |
+
|
19 |
+
const newAudio = document.createElement('audio');
|
20 |
+
newAudio.setAttribute('controls', '');
|
21 |
+
|
22 |
+
const audioSourceElem = document.createElement('source');
|
23 |
+
audioSourceElem.setAttribute('src', audioSource);
|
24 |
+
audioSourceElem.setAttribute('type', 'audio/mpeg');
|
25 |
+
|
26 |
+
newAudio.appendChild(audioSourceElem);
|
|
|
|
|
|
|
|
|
27 |
|
28 |
+
newSongDiv.appendChild(newSongTitle);
|
29 |
+
newSongDiv.appendChild(newArtist);
|
30 |
+
newSongDiv.appendChild(newAudio);
|
31 |
+
|
32 |
+
// Add the new song to the playlist
|
33 |
+
playlist.appendChild(newSongDiv);
|
34 |
+
}
|
35 |
+
|
36 |
+
|
37 |
+
|
38 |
|
39 |
|
40 |
function validateSignup() {
|