Skip to content

Commit 556a0d4

Browse files
author
TheRedstoneDEV-DE
committed
add podcasts and rework audio player
1 parent 40f7ac7 commit 556a0d4

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

js/player.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const audio_player = document.getElementsByClassName("audio-js");
2+
const button = document.getElementsByClassName("control-js");
3+
const progress = document.getElementsByClassName("progress-js");
4+
const time = document.getElementsByClassName("time-js");
5+
const time_left = document.getElementsByClassName("time-left-js");
6+
var state = false;
7+
function play_pause(i){
8+
if (state){
9+
audio_player[i].pause();
10+
button[i].innerHTML="";
11+
}else{
12+
audio_player[i].play();
13+
button[i].innerHTML="";
14+
time_left[i].innerHTML=audio_player[i].duration.toHHMMSS();
15+
}
16+
state = !state;
17+
}
18+
19+
20+
Number.prototype.toHHMMSS = function () {
21+
var sec_num = parseInt(this, 10); // don't forget the second param
22+
var hours = Math.floor(sec_num / 3600);
23+
var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
24+
var seconds = sec_num - (hours * 3600) - (minutes * 60);
25+
26+
if (hours < 10) {hours = "0"+hours;}
27+
if (minutes < 10) {minutes = "0"+minutes;}
28+
if (seconds < 10) {seconds = "0"+seconds;}
29+
return hours+':'+minutes+':'+seconds;
30+
}
31+
32+
for (let i=0; i<document.getElementsByClassName("audio-js").length; i++){
33+
audio_player[i].addEventListener("timeupdate", () => {
34+
const percent = (audio_player[i].currentTime / audio_player[i].duration) * 100;
35+
progress[i].value = percent;
36+
time[i].innerHTML=audio_player[i].currentTime.toHHMMSS();
37+
});
38+
progress[i].addEventListener("change", () => {
39+
const time = (progress[i].value / 100)*audio_player[i].duration;
40+
audio_player[i].currentTime = time;
41+
});
42+
}

podcasts.html

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<link rel="stylesheet" href="css/style.css">
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<div class="center head">
11+
<h1>TheRedstoneDEV_DE</h1>
12+
<h5>##### References #####</h5>
13+
<a class="icon" href="https://team.devellight.space:8096/TheRedstoneDEV_DE"><span class="icon"></span></a>
14+
<a class="icon" href="https://github.com/theredstonedev-de"><span class="icon"></span></a>
15+
<a class="icon" href="https://www.youtube.com/@theredstonedev_de5808"><span class="icon"></span></a>
16+
<a class="icon" href="https://devellight.space/@theredstonedev_de"><span class="icon">󰫑</span></a>
17+
</div>
18+
<div class="podcasts section">
19+
<a href="index.html" class="lnk">[<- Home]</a>
20+
<h2>## Podcasts</h2>
21+
<!---- <div class="audioplayer">
22+
<a onclick="play_pause(0)" class="control-js"></a> Soundtrack07.mp3 <br class="mobile">
23+
<span class="time-js">00:00:00</span> <br class="mobile"> <input class="progress-js" type="range" max="100" value="0"><br class="mobile"><span class="time-left-js">00:00:00</span>
24+
<audio controls style="display: none;" class="audio-js">
25+
<source src="res/Projekt.mp3" type="audio/mp3">
26+
</audio>
27+
<script src="js/player.js"></script>
28+
</div> -->
29+
<div class="text">There are currently no podcasts availlable... Sorry :(</div>
30+
</div>
31+
<div class="links section">
32+
<h2>## Local References</h2>
33+
<ul>
34+
<li><a class="lnk inactive" href="">[Blog (to be added)]</a>
35+
<li><a class="lnk" href="hardware.html">[Hardware]</a>
36+
<li><a class="lnk" href="https://github.com/TheRedstoneDEV-DE/dotfiles">[Dotfiles]</a>
37+
<li><a class="lnk" href="credits.html">[Credits]</a></li>
38+
<li><a class="lnk" href="art-lib.html">[Art libraray]</a>
39+
<li><a class="lnk inactive" href="podcasts.html">[Podcasts]</a>
40+
<li><a class="lnk" href=impressum.html>[Impressum]</a>
41+
</ul>
42+
</div>
43+
<div class="footer center">Robert Richter. All rights reserved. &copy 2024</div>
44+
</body>
45+
</html>

0 commit comments

Comments
 (0)