-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
169 lines (140 loc) · 5.1 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta author="JP.Böhm" <title>Radiostation
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/main.css" />
</head>
<body>
<div id="mySidenav" class="sidenav">
<a href="javascript:void(0)" class="closebtn" onclick="closeNav()">×</a>
<a id="pauseBtn" onclick="pauseVid()">Pause Video</a>
<a id="changeVid" onclick="changeVid()">Change Video</a>
<a id="changeStation" onclick="changeStation()">Next Station</a>
<div class="select">
<label class="select-label">Or switch to</label>
<select id="sender" class="select-text" required onchange="switchSender()">
<option value="0" disabled>another station here!</option>
<option value="0">Chillhop</option>
<option value="1">Rasta Radio</option>
<option value="2">60ies</option>
<option value="3">Klubradio</option>
</select>
</div>
<div id="radioContainer">
<p id="radioName"></p>
<audio src="http://streams.fluxfm.de/Chillhop/mp3-128/streams.fluxfm.de/" id="radioStream" autoplay="true"
controls="true" volume="1.0"></audio>
</div>
</div>
<div id="main">
<header class="v-header container">
<div class="fullscreen-video-wrap">
<video autoplay loop muted id="myVideo">
<source src="./img/bg0.mp4" type="video/mp4" />
</video>
</div>
<div class="header-overlay">
<span style="font-size:30px;cursor:pointer " id="menuBtn" onclick="openNav()">☰</span>
</div>
</header>
</div>
<script>
// Get the Controls
var video = document.getElementById("myVideo");
var pauseBtn = document.getElementById("pauseBtn");
var changeVidBtn = document.getElementById("changeVid");
var menuBtn = document.getElementById("menuBtn")
var radioStream = document.getElementById("radioStream")
var radioName = document.getElementById("radioName")
//Sources
var srcRandomVid = [
'./img/bg0.mp4',
'./img/bg1.mp4',
'./img/bg2.mp4',
'./img/bg3.mp4',
'./img/bg4.mp4',
'./img/bg5.mp4',
]
var srcRadnomRadio = [
{ id: 1, name: 'Chillhop Radio', adress: 'http://streams.fluxfm.de/Chillhop/mp3-128/streams.fluxfm.de/' },
{ id: 2, name: 'Rasta Radio', adress: 'http://streams.fluxfm.de/rastaradio/mp3-128/streams.fluxfm.de/' },
{ id: 3, name: '60´s Radio', adress: 'http://streams.fluxfm.de/60er/mp3-128/streams.fluxfm.de/' },
{ id: 4, name: 'Klub Radio', adress: 'http://streams.fluxfm.de/klubradio/mp3-128/audio/' }
]
// Var for Radio and Video Change
var currentlyVideoPlaying = 1;
var currentRadioPlaying = 0
var currentlPlayingTime;
//Helperfunctions
function incrementSrcRandomVidCount() {
currentlyVideoPlaying += 1
if (currentlyVideoPlaying === srcRandomVid.length) {
currentlyVideoPlaying = 0
}
}
function incrementRadioCount() {
currentRadioPlaying += 1
if (currentRadioPlaying == srcRadnomRadio.length) {
currentRadioPlaying = 0
}
}
function setRadioName(name) {
radioName.innerHTML = name
}
//Controlfunctions
function switchSender() {
var sel = document.getElementById("sender");
var chosenRadiosender = sel.options[sel.selectedIndex].value;
console.log(chosenRadiosender);
radioStream.src = srcRadnomRadio[chosenRadiosender].adress
setRadioName(srcRadnomRadio[chosenRadiosender].name)
}
function pauseVid() {
if (video.paused) {
video.play();
pauseBtn.innerHTML = "Pause";
} else {
video.pause();
pauseBtn.innerHTML = "Play";
}
}
function changeStation() {
radioStream.src = srcRadnomRadio[currentRadioPlaying].adress
radioName.innerHTML = srcRadnomRadio[currentRadioPlaying].name
incrementRadioCount()
}
function changeVid() {
currentlyVideoPlayingTime = video.currentTime;
video.src = srcRandomVid[currentlyVideoPlaying]
incrementSrcRandomVidCount()
pauseBtn.innerHTML = "Pause";
video.load();
video.addEventListener('loadedmetadata', function () {
video.currentTime = currentlPlayingTime;
}, false);
}
//Navcontrol
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
document.getElementById("main").style.marginLeft = "250px";
document.body.style.backgroundColor = "rgba(0,0,0,0.4)";
document.body.style.transition = "all 0.5s"
document.getElementById("mySidenav").style.opacity = "1"
menuBtn.style.opacity = "0"
setRadioName(srcRadnomRadio[currentRadioPlaying].name)
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
document.getElementById("main").style.marginLeft = "0";
document.getElementById("mySidenav").style.opacity = "0"
document.body.style.backgroundColor = "white";
menuBtn.style.opacity = "1"
menuBtn.style.transition = "all 1s"
}
document.ready = openNav()
</script>
</body>
</html>