<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0">
<title>KB405 Afstandsbediening</title>
<style>
body{
font-family:Arial,sans-serif;
background:#1a1a1a;
color:white;
text-align:center;
margin:0;
padding:20px;
}
h1{
color:#ffb000;
}
button{
width:90%;
max-width:400px;
height:60px;
margin:8px;
font-size:20px;
border:none;
border-radius:10px;
background:#ffb000;
color:black;
font-weight:bold;
}
button:active{
background:#ff8800;
}
#station{
font-size:24px;
margin:20px;
color:#00ff88;
max-height:70vh;
overflow-y:auto;
}
</style>
</head>
<body>
<h1>KB405 Radio</h1>
<div>Geen station geselecteerd</div>
<button onclick="vorige()">◀ Vorige</button>
<button onclick="volgende()">Volgende ▶</button>
<h2>Stations</h2>
<div></div>
<h2>Volume</h2>
<input
type="range"
min="0"
max="100"
value="70"
>
<div>70%</div>
<script>
const ws =
new WebSocket("ws://192.168.1.203:8765");
ws.onopen = () =>
{
console.log("Verbonden");
};
ws.onmessage = (event) =>
{
console.log(event.data);
};
ws.onerror = (e) => {
document.getElementById("station").innerText =
"WebSocket fout";
};
ws.onclose = () => {
document.getElementById("station").innerText =
"Verbinding verbroken";
};
const stations = [
"Apfelsaft",
"Barok",
"BE ONE Hits Oostende",
"Blues Drenthe FM",
"Classic Gold",
"Citysound Radio",
"Deltamusic",
"De tijdloze",
"Discoweek",
"Filmmuziek",
"FM Goud Limburg",
"Flash FM",
"Freez FM",
"Funky Channel Brugge",
"Galaxy Greece",
"Halloween Radio Movies",
"Jazz One",
"Joe Gold",
"JOE FM",
"Jukebox",
"Kiev",
"Klara",
"Klara Continuo",
"Komilfoo FM",
"Kustradio",
"Kortrijk",
"Megamix",
"M-FM Zottegem",
"MNM",
"MNM Hits",
"Moonlight",
"MooyZo Pajotteland",
"Night Lounge",
"NPO 1",
"NPO 2",
"NPO 3FM",
"NRJ Belgie",
"Ocean FM",
"Oslo InterFM",
"Oudepiratenhits",
"Radio 1 BE",
"Radio 2 BE",
"Radio 5",
"Radio 538",
"Radio Contact",
"Radio Kompas Diksmuide",
"Radio Melodie Schlagers",
"Radio Meteor",
"Radio Mi Amigo",
"Radio Ninove",
"Radio Nostalgie",
"Radio Nostalgie Plus",
"Radio Oostende",
"Radio Pros Aalst",
"Retro Hits",
"Silver Radio",
"Stadsradio Vlaanderen",
"Starradio Oud-Turnhout",
"Stockholm",
"Studio Brussel",
"Sunshine FM",
"The Beat",
"Topbam",
"Top Radio",
"Top Zen",
"VBRO",
"WRadio Roeselare",
"Q Foute Radio",
"Qmusic",
"QMusic Allstars",
"Radio Melinda",
"Radio Noordzee",
"Noordzee Gold",
];
let huidige = 0;
const vol = document.getElementById("volume");
vol.addEventListener("input", () => {
document.getElementById("volwaarde").innerText =
vol.value + "%";
ws.send("VOL:" + vol.value);
});
function zend(index)
{
huidige = index;
document.getElementById("station").innerText =
stations[index];
if (ws.readyState === WebSocket.OPEN)
{
ws.send("SET:" + index);
}
}
function volgende()
{
huidige++;
if(huidige >= stations.length)
huidige = 0;
zend(huidige);
}
function vorige()
{
huidige--;
if(huidige < 0)
huidige = stations.length-1;
zend(huidige);
}
const lijst = document.getElementById("stations");
stations.forEach((naam,index)=>
{
let knop = document.createElement("button");
knop.innerText = naam;
knop.onclick = () => zend(index);
lijst.appendChild(knop);
});
</script>
</body>
</html>