summaryrefslogtreecommitdiff
path: root/templates/var
diff options
context:
space:
mode:
authorheqnx <root@heqnx.com>2025-07-05 13:47:40 +0300
committerheqnx <root@heqnx.com>2025-07-05 13:47:40 +0300
commit7ff2aaef6717b97278d97e40143e0dec22924fa5 (patch)
tree2124d5358bdb58caf9147f2a022e2dc65c8ae458 /templates/var
parente95318bcada0feb1dcdd44773e690b2addc6de38 (diff)
downloadansible-icecast2-7ff2aaef6717b97278d97e40143e0dec22924fa5.tar.gz
ansible-icecast2-7ff2aaef6717b97278d97e40143e0dec22924fa5.zip
improvements, added metadata to script convertor, added spinnet, added track info to html
Diffstat (limited to 'templates/var')
-rw-r--r--templates/var/www/html/index.html88
-rw-r--r--templates/var/www/html/style.css105
2 files changed, 193 insertions, 0 deletions
diff --git a/templates/var/www/html/index.html b/templates/var/www/html/index.html
new file mode 100644
index 0000000..14ed148
--- /dev/null
+++ b/templates/var/www/html/index.html
@@ -0,0 +1,88 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
+ <link rel="icon" href="data:," />
+ <link rel="stylesheet" href="style.css" />
+ <title>{{ radio_name }}</title>
+</head>
+<body>
+ <div class="index-container">
+ <div class="player-wrapper">
+ <a id="radioButton" class="btn" href="#">Play</a>
+ <div id="info"></div>
+ <audio id="radioPlayer" hidden>
+ <source src="/stream" type="audio/ogg" />
+ Your browser does not support the audio element.
+ </audio>
+ </div>
+ </div>
+
+ <script>
+ const player = document.getElementById('radioPlayer');
+ const button = document.getElementById('radioButton');
+ const infoEl = document.getElementById('info');
+
+ button.addEventListener('click', () => {
+ if (player.paused) {
+ player.play();
+ button.textContent = 'Stop';
+ } else {
+ player.pause();
+ player.currentTime = 0;
+ button.textContent = 'Play';
+ }
+ });
+
+ let spinnerInterval;
+
+ function startSpinner() {
+ const spinnerChars = ['|', '/', '-', '\\'];
+ let i = 0;
+ spinnerInterval = setInterval(() => {
+ infoEl.textContent = `${spinnerChars[i++ % spinnerChars.length]}`;
+ }, 100);
+ }
+
+ function stopSpinner() {
+ clearInterval(spinnerInterval);
+ }
+
+ let spinnerHasRun = false;
+
+ async function fetchCurrentTrack() {
+ if (!spinnerHasRun) {
+ startSpinner();
+ await new Promise(resolve => setTimeout(resolve, 3000));
+ }
+
+ try {
+ const response = await fetch('/info');
+ if (!response.ok) throw new Error('Network response was not ok');
+
+ const data = await response.json();
+ const source = data.icestats.source;
+
+ const title = source.title || 'Unknown';
+ const bitrate = source['ice-bitrate'] || 0;
+ const listeners = source.listeners || 0;
+ const listenerLabel = listeners === 1 ? 'listener' : 'listeners';
+
+ stopSpinner();
+ infoEl.textContent = `${title} | ${bitrate} kbps | ${listeners} ${listenerLabel}`;
+
+ spinnerHasRun = true;
+
+ } catch (error) {
+ stopSpinner();
+ infoEl.textContent = 'Error loading track info';
+ console.error(error);
+ }
+ }
+
+ fetchCurrentTrack();
+ setInterval(fetchCurrentTrack, 10000);
+ </script>
+</body>
+</html>
diff --git a/templates/var/www/html/style.css b/templates/var/www/html/style.css
new file mode 100644
index 0000000..542b59c
--- /dev/null
+++ b/templates/var/www/html/style.css
@@ -0,0 +1,105 @@
+:root {
+ --color-black: #000000;
+ --color-dark-cyan: #008080;
+ --color-light-gray: #C0C0C0;
+ --color-dark-gray: #808080;
+}
+
+@font-face {
+ font-family: 'MorePerfectDOSVGA';
+ src: url('MorePerfectDOSVGA.ttf') format('truetype');
+}
+
+::-webkit-scrollbar {
+ display: none;
+}
+
+* {
+ -ms-overflow-style: none;
+ scrollbar-width: none;
+}
+
+body {
+ background-color: var(--color-black);
+ color: var(--color-light-gray);
+ font-family: 'MorePerfectDOSVGA', monospace;
+ font-size: 14px;
+ line-height: 1.6;
+ margin: 0 auto;
+ padding: 0;
+ overflow: hidden;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ height: 100vh;
+ text-align: center;
+}
+
+.index-container {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ height: 100vh;
+ width: 100%;
+ padding: 0 10px;
+ box-sizing: border-box;
+}
+
+.player-wrapper {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 8px;
+ max-width: 100%;
+ width: 320px;
+}
+
+.btn {
+ color: var(--color-black);
+ background-color: var(--color-light-gray);
+ padding: 8px 16px;
+ text-decoration: none;
+ font-size: 16px;
+ font-weight: bold;
+ position: relative;
+ display: inline-block;
+ cursor: pointer;
+ user-select: none;
+}
+
+.btn::before {
+ content: '';
+ background-color: var(--color-dark-gray);
+ position: absolute;
+ top: 4px;
+ left: 4px;
+ width: 100%;
+ height: 100%;
+ z-index: -1;
+}
+
+.btn:hover::before {
+ background-color: var(--color-dark-cyan);
+}
+
+#info {
+ font-size: 14px;
+ color: var(--color-light-gray);
+ min-height: 18px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+@media (max-width: 400px) {
+ .btn {
+ font-size: 14px;
+ padding: 6px 12px;
+ }
+ #info {
+ font-size: 12px;
+ }
+ .player-wrapper {
+ width: 90vw;
+ }
+}