asteroid/template/front-page.chtml

153 lines
5.9 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<title data-text="title">🎵 ASTEROID RADIO 🎵</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="/asteroid/static/asteroid.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=VT323&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<header>
<h1 data-text="station-name">🎵 ASTEROID RADIO 🎵</h1>
<nav>
<a href="/asteroid/">Home</a>
<a href="/asteroid/player">Player</a>
<a href="/asteroid/admin">Admin</a>
<a href="/asteroid/status">Status</a>
<a href="/asteroid/login">Login</a>
<a href="/asteroid/register">Register</a>
</nav>
</header>
<main>
<div class="status">
<h2>Station Status</h2>
<p data-text="status-message">🟢 LIVE - Broadcasting asteroid music for hackers</p>
<p>Current listeners: <span data-text="listeners">0</span></p>
<p>Stream quality: <span data-text="stream-quality">128kbps MP3</span></p>
</div>
<div class="live-stream">
<h2>🔴 LIVE STREAM</h2>
<!-- Stream Quality Selector -->
<div style="margin: 10px 0;">
<label for="stream-quality"><strong>Quality:</strong></label>
<select id="stream-quality" onchange="changeStreamQuality()" style="margin-left: 10px; padding: 5px;">
<option value="aac">AAC 96kbps (Recommended)</option>
<option value="mp3">MP3 128kbps (Compatible)</option>
<option value="low">MP3 64kbps (Low Bandwidth)</option>
</select>
</div>
<p><strong>Stream URL:</strong> <code id="stream-url">http://localhost:8000/asteroid.aac</code></p>
<p><strong>Format:</strong> <span id="stream-format">AAC 96kbps Stereo</span></p>
<p><strong>Status:</strong> <span style="color: #00ff00;">● BROADCASTING</span></p>
<audio id="live-audio" controls style="width: 100%; margin: 10px 0;">
<source id="audio-source" src="http://localhost:8000/asteroid.aac" type="audio/aac">
Your browser does not support the audio element.
</audio>
</div>
<div class="now-playing">
<h2>Now Playing</h2>
<p>Artist: <span data-text="now-playing-artist">The Void</span></p>
<p>Track: <span data-text="now-playing-track">Silence</span></p>
<p>Listeners: <span data-text="listeners">0</span></p>
</div>
</main>
</div>
<script>
// Stream quality configuration
const streamConfig = {
aac: {
url: 'http://localhost:8000/asteroid.aac',
format: 'AAC 96kbps Stereo',
type: 'audio/aac',
mount: 'asteroid.aac'
},
mp3: {
url: 'http://localhost:8000/asteroid.mp3',
format: 'MP3 128kbps Stereo',
type: 'audio/mpeg',
mount: 'asteroid.mp3'
},
low: {
url: 'http://localhost:8000/asteroid-low.mp3',
format: 'MP3 64kbps Stereo',
type: 'audio/mpeg',
mount: 'asteroid-low.mp3'
}
};
// Change stream quality
function changeStreamQuality() {
const selector = document.getElementById('stream-quality');
const config = streamConfig[selector.value];
// Update UI elements
document.getElementById('stream-url').textContent = config.url;
document.getElementById('stream-format').textContent = config.format;
// Update audio player
const audioElement = document.getElementById('live-audio');
const sourceElement = document.getElementById('audio-source');
const wasPlaying = !audioElement.paused;
const currentTime = audioElement.currentTime;
sourceElement.src = config.url;
sourceElement.type = config.type;
audioElement.load();
// Resume playback if it was playing
if (wasPlaying) {
audioElement.play().catch(e => console.log('Autoplay prevented:', e));
}
}
// Update now playing info from Icecast
function updateNowPlaying() {
fetch('/asteroid/api/icecast-status')
.then(response => response.json())
.then(data => {
if (data.icestats && data.icestats.source) {
// Find the high quality stream (asteroid.mp3)
const sources = Array.isArray(data.icestats.source) ? data.icestats.source : [data.icestats.source];
const mainStream = sources.find(s => s.listenurl && s.listenurl.includes('asteroid.mp3'));
if (mainStream && mainStream.title) {
// Parse "Artist - Track" format
const titleParts = mainStream.title.split(' - ');
const artist = titleParts.length > 1 ? titleParts[0] : 'Unknown Artist';
const track = titleParts.length > 1 ? titleParts.slice(1).join(' - ') : mainStream.title;
document.querySelector('[data-text="now-playing-artist"]').textContent = artist;
document.querySelector('[data-text="now-playing-track"]').textContent = track;
document.querySelector('[data-text="listeners"]').textContent = mainStream.listeners || '0';
// Update stream status
const statusElement = document.querySelector('.live-stream p:nth-child(3) span');
if (statusElement) {
statusElement.textContent = '● LIVE - ' + track;
statusElement.style.color = '#00ff00';
}
}
}
})
.catch(error => console.log('Could not fetch stream status:', error));
}
// Update every 10 seconds
updateNowPlaying();
setInterval(updateNowPlaying, 10000);
</script>
</body>
</html>