Files
donut/internal/web/index.html
Leandro Moreira e8188cbfc5 split components
2024-01-26 19:13:23 -03:00

62 lines
1.7 KiB
HTML

<html>
<head>
<title>donut</title>
<script type="module" src="https://unpkg.com/donut-video-element@0.0.3"></script>
</head>
<body>
<b> SRT Host </b>
<input type="text" id="srt-host"> <br />
<b> SRT Port </b>
<input type="text" id="srt-port" /> <br />
<b> SRT Stream ID </b>
<input type="text" id="srt-stream-id" /> <br />
<button onclick="onConnect()"> Connect </button>
<donut-video server="http://localhost:8080" controls />
</body>
<script>
function docReady(fn) {
if (document.readyState === "complete" || document.readyState === "interactive") {
setTimeout(fn, 1);
} else {
document.addEventListener("DOMContentLoaded", fn);
}
}
docReady(function () {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const player = document.querySelectorAll('donut-video')[0];
window.onConnect = () => {
let srtHost = document.getElementById('srt-host').value;
let srtPort = document.getElementById('srt-port').value;
let srtStreamId = document.getElementById('srt-stream-id').value;
let src = 'srt://' + srtHost + ':' + srtPort + '/' + srtStreamId;
player.src = src;
player.play();
}
if (urlParams.has('srtHost')) {
document.getElementById('srt-host').value = urlParams.get('srtHost');
}
if (urlParams.has('srtPort')) {
document.getElementById('srt-port').value = urlParams.get('srtPort');
}
if (urlParams.has('srtStreamId')) {
document.getElementById('srt-stream-id').value = urlParams.get('srtStreamId');
}
if (urlParams.get('autoplay') === "true") {
onConnect();
}
});
</script>
</html>