Files
dropshell-templates/squashkiwi-streaming/config/web/test.html
Your Name 7d1a1b3f0c
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 22s
config: Add 3 and update 5 files
2025-09-02 00:11:15 +12:00

165 lines
6.3 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stream Test</title>
<style>
body {
font-family: monospace;
padding: 20px;
background: #1a1a1a;
color: #0f0;
}
.test-section {
margin: 20px 0;
padding: 15px;
border: 1px solid #0f0;
background: #000;
}
button {
background: #0f0;
color: #000;
border: none;
padding: 10px 20px;
margin: 5px;
cursor: pointer;
font-family: monospace;
font-weight: bold;
}
button:hover {
background: #0a0;
}
.status {
margin: 10px 0;
padding: 10px;
background: #111;
}
.success { color: #0f0; }
.error { color: #f00; }
.info { color: #ff0; }
</style>
</head>
<body>
<h1>SquashKiwi Stream Test Page</h1>
<div class="test-section">
<h2>Available Paths</h2>
<button onclick="checkPaths()">Check MediaMTX Paths</button>
<div id="paths-status" class="status">Click to check available paths...</div>
</div>
<div class="test-section">
<h2>Test Streams</h2>
<button onclick="testStream('court')">Test 'court' (H265)</button>
<button onclick="testStream('court_h264')">Test 'court_h264'</button>
<button onclick="testStream('court_sub')">Test 'court_sub'</button>
<button onclick="testStream('court_main')">Test 'court_main'</button>
<div id="stream-status" class="status">Select a stream to test...</div>
</div>
<div class="test-section">
<h2>HLS Test</h2>
<video id="hls-video" controls style="width: 100%; max-width: 600px;"></video>
<div id="hls-status" class="status">HLS player ready...</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<script>
async function checkPaths() {
const status = document.getElementById('paths-status');
status.innerHTML = '<span class="info">Checking paths...</span>';
try {
// Try direct access to MediaMTX API on port 9997
const response = await fetch('http://' + window.location.hostname + ':9997/v3/paths/list');
const data = await response.json();
let html = '<span class="success">Found ' + data.itemCount + ' path(s):</span><br>';
data.items.forEach(item => {
html += `<br>Path: <b>${item.name}</b>`;
html += `<br> Ready: ${item.ready ? '✓' : '✗'}`;
html += `<br> Tracks: ${item.tracks ? item.tracks.join(', ') : 'none'}`;
html += `<br> Readers: ${item.readers ? item.readers.length : 0}`;
html += '<br>';
});
status.innerHTML = html;
} catch (error) {
status.innerHTML = '<span class="error">Error: ' + error.message + '</span>';
}
}
async function testStream(streamName) {
const status = document.getElementById('stream-status');
const video = document.getElementById('hls-video');
status.innerHTML = `<span class="info">Testing stream: ${streamName}...</span>`;
// Test HLS
const hlsUrl = `/hls/${streamName}/index.m3u8`;
status.innerHTML += `<br>HLS URL: ${hlsUrl}`;
try {
const response = await fetch(hlsUrl, { method: 'HEAD' });
if (response.ok) {
status.innerHTML += '<br><span class="success">HLS playlist exists!</span>';
loadHLS(hlsUrl);
} else {
status.innerHTML += `<br><span class="error">HLS playlist not found (${response.status})</span>`;
}
} catch (error) {
status.innerHTML += '<br><span class="error">HLS test failed: ' + error.message + '</span>';
}
// Test WebRTC
const webrtcUrl = `/webrtc/${streamName}/whep`;
status.innerHTML += `<br><br>WebRTC URL: ${webrtcUrl}`;
try {
const response = await fetch(webrtcUrl, { method: 'OPTIONS' });
if (response.ok) {
status.innerHTML += '<br><span class="success">WebRTC endpoint exists!</span>';
} else {
status.innerHTML += `<br><span class="error">WebRTC endpoint issue (${response.status})</span>`;
}
} catch (error) {
status.innerHTML += '<br><span class="error">WebRTC test failed: ' + error.message + '</span>';
}
}
function loadHLS(url) {
const video = document.getElementById('hls-video');
const status = document.getElementById('hls-status');
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(url);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function() {
status.innerHTML = '<span class="success">HLS stream loaded! Press play to start.</span>';
video.play().catch(e => {
status.innerHTML += '<br><span class="info">Auto-play blocked. Click play button.</span>';
});
});
hls.on(Hls.Events.ERROR, function(event, data) {
if (data.fatal) {
status.innerHTML = '<span class="error">HLS Error: ' + data.details + '</span>';
}
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = url;
status.innerHTML = '<span class="info">Using native HLS support</span>';
} else {
status.innerHTML = '<span class="error">HLS not supported in this browser</span>';
}
}
// Check paths on load
window.onload = () => {
checkPaths();
};
</script>
</body>
</html>