-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (105 loc) · 3.52 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Audio Player</title>
<link rel="stylesheet" href="styles.css" />
<script
src="https://kit.fontawesome.com/122d948e86.js"
crossorigin="anonymous"
></script>
</head>
<body>
<div class="container">
<div class="music-player">
<nav>
<a href="home.html" class="circle"
><i class="fa-solid fa-angle-left"></i>
</a>
<a
href="https://taylorswift.fandom.com/wiki/All_Too_Well_(10_Minute_Version)"
target="_blank"
class="circle"
><i class="fa-solid fa-bars"></i
></a>
</nav>
<img src="Media/RED.png" alt="RED TV Album Cover" class="Cover" />
<h1>
All Too Well(10 Minute Version)(Taylor's Version)(From The Vault)
</h1>
<p>Taylor Swift</p>
<audio id="song">
<source
src="Media/Taylor Swift All Too Well 10 Minute.mp3"
type="audio/mpeg"
/>
</audio>
<input type="range" value="0" id="progress" />
<div class="time">
<span id="currentTime">0:00</span> /
<span id="totalTime">0:00</span>
</div>
<div class="controls">
<div><i class="fa-solid fa-backward"></i></div>
<div onclick="playPause()">
<i class="fa-solid fa-play" id="ctrlIcon"></i>
</div>
<div><i class="fa-solid fa-forward"></i></div>
</div>
</div>
</div>
<script>
let progress = document.getElementById("progress");
let song = document.getElementById("song");
let ctrlIcon = document.getElementById("ctrlIcon");
song.onloadeddata = function () {
progress.max = song.duration;
progress.value = song.currentTime;
};
function playPause() {
if (ctrlIcon.classList.contains("fa-pause")) {
song.pause();
ctrlIcon.classList.remove("fa-pause");
ctrlIcon.classList.add("fa-play");
} else {
song.play();
ctrlIcon.classList.add("fa-pause");
ctrlIcon.classList.remove("fa-play");
}
}
if (song.play()) {
setInterval(() => {
progress.value = song.currentTime;
}, 500);
}
progress.onchange = function () {
song.play();
song.currentTime = progress.value;
ctrlIcon.classList.add("fa-pause");
ctrlIcon.classList.remove("fa-play");
};
let currentTime = document.getElementById("currentTime");
let totalTime = document.getElementById("totalTime");
song.onloadeddata = function () {
progress.max = song.duration;
progress.value = song.currentTime;
// Display total song duration
totalTime.textContent = formatTime(song.duration);
};
// Update the time and progress bar during playback
setInterval(() => {
if (!song.paused) {
progress.value = song.currentTime;
currentTime.textContent = formatTime(song.currentTime);
}
}, 500);
// Format time in minutes:seconds
function formatTime(seconds) {
let min = Math.floor(seconds / 60);
let sec = Math.floor(seconds % 60);
return `${min}:${sec < 10 ? "0" : ""}${sec}`;
}
</script>
</body>
</html>