-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplaylist.html
113 lines (99 loc) · 3.23 KB
/
playlist.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html>
<head>
<title>Podcast Playlist</title>
<link rel="shortcut icon" href="./favicon.svg" type="image/svg+xml">
<link rel="stylesheet" href="./assets/css/style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Josefin+Sans:wght@400;500;700&display=swap" rel="stylesheet">
<style>
/* Internal CSS */
body {
font-family: Arial, sans-serif;
background-color: var(--russian-violet);
}
h1 {
text-align: center;
color: whitesmoke;
}
.container {
display: flex;
justify-content: space-around;
align-items: flex-start;
padding: 20px;
background-color: var(--russian-violet);
}
.playlist-container, .history-container {
flex: 1;
background-color: var(--russian-violet);
border: 1px solid #ddd;
padding: 20px;
margin: 10px;
}
h2 {
font-size: 25px;
color: white;
}
ul {
list-style: none;
padding: 0;
}
ul li {
margin: 10px 0;
}
ul li a {
text-decoration: none;
color: white;
}
ul li a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<h1>Podcast Playlist</h1>
<div class="container">
<div class="playlist-container">
<h2>Playlist</h2>
<ul id="playlist">
<li><a href="podcast1.mp3">Podcast 1</a></li>
<li><a href="podcast2.mp3">Podcast 2</a></li>
<li><a href="podcast3.mp3">Podcast 3</a></li>
<!-- Add more podcasts as needed -->
</ul>
</div>
<div class="history-container">
<h2>Listening History</h2>
<ul id="history">
<!-- Listening history will be displayed here -->
</ul>
</div>
</div>
<audio controls id="audioPlayer">
<source src="" type="audio/mpeg">
</audio>
<script>
const playlist = document.getElementById("playlist");
const audioPlayer = document.getElementById("audioPlayer");
const history = document.getElementById("history");
playlist.addEventListener("click", (event) => {
if (event.target.tagName === "A") {
event.preventDefault();
const podcastFile = event.target.getAttribute("href");
audioPlayer.src = podcastFile;
audioPlayer.play();
addToHistory(event.target.textContent, podcastFile);
}
});
function addToHistory(podcastTitle, podcastFile) {
const historyItem = document.createElement("li");
const historyLink = document.createElement("a");
historyLink.href = podcastFile;
historyLink.textContent = podcastTitle;
historyItem.appendChild(historyLink);
history.appendChild(historyItem);
}
</script>
</body>
</html>