Add direct stream URL input support to web UI

This commit is contained in:
eduard256
2026-04-03 20:03:45 +00:00
parent 4880e1ad14
commit d59816543d
2 changed files with 20 additions and 9 deletions
+12 -7
View File
@@ -326,8 +326,16 @@
var dbStreams = []; // from /api/streams var dbStreams = []; // from /api/streams
var customStreams = []; // user-added var customStreams = []; // user-added
// Pre-populate custom streams from "url" query parameter (supports multiple)
params.getAll('url').forEach(function(u) {
u = u.trim();
if (u && u.indexOf('://') !== -1 && customStreams.indexOf(u) === -1) {
customStreams.push(u);
}
});
// subtitle // subtitle
document.getElementById('subtitle').textContent = ip ? 'Target: ' + ip : ''; document.getElementById('subtitle').textContent = ip ? 'Target: ' + ip : 'Add stream URLs manually';
// back // back
document.getElementById('btn-back').addEventListener('click', function() { document.getElementById('btn-back').addEventListener('click', function() {
@@ -339,7 +347,8 @@
async function loadStreams() { async function loadStreams() {
if (!ids || !ip) { if (!ids || !ip) {
renderError('Missing required parameters (ids, ip)'); // No parameters — show empty list with add section
renderAll();
return; return;
} }
@@ -359,11 +368,7 @@
var data = await r.json(); var data = await r.json();
dbStreams = data.streams || []; dbStreams = data.streams || [];
if (dbStreams.length === 0 && customStreams.length === 0) { renderAll();
renderEmpty();
} else {
renderAll();
}
} catch (e) { } catch (e) {
renderError('Connection error: ' + e.message); renderError('Connection error: ' + e.message);
} }
+8 -2
View File
@@ -257,7 +257,7 @@
</span> </span>
</label> </label>
<input type="text" id="ip" class="input input-large" placeholder="192.168.1.100" autocomplete="off" spellcheck="false"> <input type="text" id="ip" class="input input-large" placeholder="192.168.1.100" autocomplete="off" spellcheck="false">
<p class="hint">IP address of the camera</p> <p class="hint">IP address or stream URL (rtsp://, http://, ...)</p>
</div> </div>
<button id="btn-check" class="btn btn-primary btn-large">Check Address</button> <button id="btn-check" class="btn btn-primary btn-large">Check Address</button>
@@ -295,7 +295,13 @@
async function checkAddress() { async function checkAddress() {
const ip = ipInput.value.trim(); const ip = ipInput.value.trim();
if (!ip) { showToast('Enter an IP address'); return; } if (!ip) { showToast('Enter an IP address or stream URL'); return; }
// Direct stream URL — skip probe, go straight to create.html
if (ip.indexOf('://') !== -1) {
window.location.href = 'create.html?url=' + encodeURIComponent(ip);
return;
}
btnCheck.disabled = true; btnCheck.disabled = true;
btnCheck.textContent = 'Checking...'; btnCheck.textContent = 'Checking...';