
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 22s
329 lines
11 KiB
HTML
329 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>SquashKiwi Court Stream</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
color: white;
|
|
}
|
|
.container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
header {
|
|
text-align: center;
|
|
padding: 30px 0;
|
|
}
|
|
h1 {
|
|
font-size: 2.5rem;
|
|
margin-bottom: 10px;
|
|
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
|
|
}
|
|
.video-section {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
backdrop-filter: blur(10px);
|
|
margin-bottom: 20px;
|
|
}
|
|
.video-container {
|
|
position: relative;
|
|
padding-bottom: 56.25%;
|
|
height: 0;
|
|
background: black;
|
|
}
|
|
video {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
.video-controls {
|
|
padding: 15px;
|
|
background: rgba(0, 0, 0, 0.3);
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
flex-wrap: wrap;
|
|
gap: 10px;
|
|
}
|
|
.status-badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 8px 16px;
|
|
border-radius: 20px;
|
|
font-weight: 600;
|
|
font-size: 0.9rem;
|
|
}
|
|
.status-badge.live {
|
|
background: #10b981;
|
|
animation: pulse 2s infinite;
|
|
}
|
|
.status-badge.offline {
|
|
background: #ef4444;
|
|
}
|
|
@keyframes pulse {
|
|
0%, 100% { opacity: 1; }
|
|
50% { opacity: 0.8; }
|
|
}
|
|
.btn {
|
|
padding: 8px 16px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
color: white;
|
|
cursor: pointer;
|
|
font-size: 0.9rem;
|
|
transition: all 0.3s;
|
|
}
|
|
.btn:hover {
|
|
background: rgba(255, 255, 255, 0.3);
|
|
transform: translateY(-2px);
|
|
}
|
|
.quality-selector {
|
|
display: flex;
|
|
gap: 5px;
|
|
}
|
|
.quality-btn {
|
|
padding: 5px 10px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
background: transparent;
|
|
color: white;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
font-size: 0.85rem;
|
|
}
|
|
.quality-btn.active {
|
|
background: rgba(255, 255, 255, 0.3);
|
|
}
|
|
.info-section {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
backdrop-filter: blur(10px);
|
|
margin-bottom: 20px;
|
|
}
|
|
.recordings-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
|
|
gap: 15px;
|
|
margin-top: 20px;
|
|
}
|
|
.recording-card {
|
|
background: rgba(255, 255, 255, 0.1);
|
|
border-radius: 8px;
|
|
padding: 15px;
|
|
transition: all 0.3s;
|
|
cursor: pointer;
|
|
}
|
|
.recording-card:hover {
|
|
background: rgba(255, 255, 255, 0.2);
|
|
transform: translateY(-2px);
|
|
}
|
|
</style>
|
|
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<header>
|
|
<h1>🎾 SquashKiwi Court Stream</h1>
|
|
</header>
|
|
|
|
<div class="video-section">
|
|
<div class="video-container">
|
|
<video id="video" controls autoplay muted></video>
|
|
</div>
|
|
<div class="video-controls">
|
|
<div class="status-badge offline" id="status">
|
|
<span>Connecting...</span>
|
|
</div>
|
|
<div class="quality-selector">
|
|
<button class="quality-btn active" data-quality="auto">Auto</button>
|
|
<button class="quality-btn" data-quality="high">HD</button>
|
|
<button class="quality-btn" data-quality="low">SD</button>
|
|
</div>
|
|
<div>
|
|
<button class="btn" onclick="toggleFullscreen()">📺 Fullscreen</button>
|
|
<button class="btn" onclick="refreshStream()">🔄 Refresh</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="info-section">
|
|
<h2>Recent Recordings</h2>
|
|
<div class="recordings-grid" id="recordings">
|
|
<div class="recording-card">
|
|
<div>Loading recordings...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const config = {
|
|
courtId: new URLSearchParams(window.location.search).get('court') || 'court',
|
|
hlsUrl: '/hls/'
|
|
};
|
|
|
|
let hls = null;
|
|
|
|
function initPlayer() {
|
|
const video = document.getElementById('video');
|
|
const streamUrl = `${config.hlsUrl}${config.courtId}/index.m3u8`;
|
|
|
|
if (Hls.isSupported()) {
|
|
hls = new Hls({
|
|
liveSyncDurationCount: 3,
|
|
liveMaxLatencyDurationCount: 10,
|
|
enableWorker: true,
|
|
lowLatencyMode: true
|
|
});
|
|
|
|
hls.loadSource(streamUrl);
|
|
hls.attachMedia(video);
|
|
|
|
hls.on(Hls.Events.MANIFEST_PARSED, function() {
|
|
video.play().catch(e => console.log('Autoplay blocked:', e));
|
|
updateStatus(true);
|
|
});
|
|
|
|
hls.on(Hls.Events.ERROR, function(event, data) {
|
|
console.error('HLS error:', data);
|
|
if (data.fatal) {
|
|
updateStatus(false);
|
|
switch(data.type) {
|
|
case Hls.ErrorTypes.NETWORK_ERROR:
|
|
setTimeout(() => hls.startLoad(), 3000);
|
|
break;
|
|
case Hls.ErrorTypes.MEDIA_ERROR:
|
|
hls.recoverMediaError();
|
|
break;
|
|
default:
|
|
setTimeout(initPlayer, 5000);
|
|
break;
|
|
}
|
|
}
|
|
});
|
|
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
|
video.src = streamUrl;
|
|
video.addEventListener('loadedmetadata', function() {
|
|
video.play().catch(e => console.log('Autoplay blocked:', e));
|
|
updateStatus(true);
|
|
});
|
|
video.addEventListener('error', function() {
|
|
updateStatus(false);
|
|
setTimeout(initPlayer, 5000);
|
|
});
|
|
}
|
|
}
|
|
|
|
function updateStatus(live) {
|
|
const statusEl = document.getElementById('status');
|
|
if (live) {
|
|
statusEl.className = 'status-badge live';
|
|
statusEl.innerHTML = '<span>🔴 LIVE</span>';
|
|
} else {
|
|
statusEl.className = 'status-badge offline';
|
|
statusEl.innerHTML = '<span>⚫ OFFLINE</span>';
|
|
}
|
|
}
|
|
|
|
document.querySelector('.quality-selector').addEventListener('click', (e) => {
|
|
if (e.target.classList.contains('quality-btn')) {
|
|
document.querySelectorAll('.quality-btn').forEach(btn => {
|
|
btn.classList.remove('active');
|
|
});
|
|
e.target.classList.add('active');
|
|
|
|
const quality = e.target.dataset.quality;
|
|
if (hls) {
|
|
switch(quality) {
|
|
case 'auto':
|
|
hls.currentLevel = -1;
|
|
break;
|
|
case 'high':
|
|
hls.currentLevel = hls.levels.length - 1;
|
|
break;
|
|
case 'low':
|
|
hls.currentLevel = 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
function toggleFullscreen() {
|
|
const video = document.getElementById('video');
|
|
if (!document.fullscreenElement) {
|
|
video.requestFullscreen().catch(err => {
|
|
console.error('Fullscreen error:', err);
|
|
});
|
|
} else {
|
|
document.exitFullscreen();
|
|
}
|
|
}
|
|
|
|
function refreshStream() {
|
|
if (hls) {
|
|
hls.destroy();
|
|
}
|
|
initPlayer();
|
|
}
|
|
|
|
async function loadRecordings() {
|
|
try {
|
|
const response = await fetch(`/api/recordings?court=${config.courtId}`);
|
|
const data = await response.json();
|
|
|
|
const container = document.getElementById('recordings');
|
|
if (!data.recordings || data.recordings.length === 0) {
|
|
container.innerHTML = '<div class="recording-card"><div>No recordings available</div></div>';
|
|
return;
|
|
}
|
|
|
|
container.innerHTML = data.recordings.map(rec => `
|
|
<div class="recording-card" onclick="playRecording('${rec.file}')">
|
|
<div>${rec.date}</div>
|
|
<div style="margin-top: 10px; font-size: 0.85rem;">
|
|
${rec.size} • Click to play
|
|
</div>
|
|
</div>
|
|
`).join('');
|
|
} catch (e) {
|
|
console.error('Failed to load recordings:', e);
|
|
}
|
|
}
|
|
|
|
function playRecording(file) {
|
|
const video = document.getElementById('video');
|
|
if (hls) {
|
|
hls.destroy();
|
|
}
|
|
video.src = `/recordings/${config.courtId}/${file}`;
|
|
video.play();
|
|
updateStatus(false);
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
initPlayer();
|
|
loadRecordings();
|
|
setInterval(loadRecordings, 30000);
|
|
});
|
|
|
|
window.addEventListener('beforeunload', () => {
|
|
if (hls) {
|
|
hls.destroy();
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |