fix: remove HLS video player from listener page
This commit is contained in:
parent
c4d9fad60f
commit
075deff7bd
|
|
@ -23,12 +23,6 @@
|
|||
|
||||
<canvas id="viz-listener" width="400" height="100"></canvas>
|
||||
|
||||
<!-- HLS video player — shown only when the SRT stream is active -->
|
||||
<div id="hls-player-container" {% if not live %}hidden{% endif %} style="width:100%;margin-top:16px;text-align:center;">
|
||||
<video id="hls-video" controls autoplay muted playsinline
|
||||
style="width:100%;max-width:720px;border-radius:12px;background:#000;"></video>
|
||||
</div>
|
||||
|
||||
<!-- Enable Audio Button (shown when autoplay is blocked) -->
|
||||
<button class="enable-audio-btn" id="enable-audio-btn" onclick="enableListenerAudio()">
|
||||
<span class="audio-icon">🎧</span>
|
||||
|
|
@ -47,51 +41,21 @@
|
|||
|
||||
<script src="https://cdn.socket.io/4.5.4/socket.io.min.js"></script>
|
||||
<script src="listener.js?v=2.0"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@1/dist/hls.min.js"></script>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
var HLS_URL = {{ hls_url | tojson }};
|
||||
var badge = document.getElementById('live-badge');
|
||||
var container = document.getElementById('hls-player-container');
|
||||
var video = document.getElementById('hls-video');
|
||||
var hlsInstance = null;
|
||||
|
||||
function startHls() {
|
||||
if (hlsInstance) return;
|
||||
if (typeof Hls !== 'undefined' && Hls.isSupported()) {
|
||||
hlsInstance = new Hls({ lowLatencyMode: true });
|
||||
hlsInstance.loadSource(HLS_URL);
|
||||
hlsInstance.attachMedia(video);
|
||||
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
// Safari — native HLS support
|
||||
video.src = HLS_URL;
|
||||
}
|
||||
}
|
||||
|
||||
function stopHls() {
|
||||
if (hlsInstance) { hlsInstance.destroy(); hlsInstance = null; }
|
||||
video.src = '';
|
||||
}
|
||||
|
||||
function setLive(isLive) {
|
||||
if (!badge) return;
|
||||
if (isLive) {
|
||||
if (badge) badge.removeAttribute('hidden');
|
||||
if (container) container.removeAttribute('hidden');
|
||||
startHls();
|
||||
badge.removeAttribute('hidden');
|
||||
} else {
|
||||
if (badge) badge.setAttribute('hidden', '');
|
||||
if (container) container.setAttribute('hidden', '');
|
||||
stopHls();
|
||||
badge.setAttribute('hidden', '');
|
||||
}
|
||||
}
|
||||
|
||||
// Server-rendered as live — start HLS immediately.
|
||||
{% if live %}startHls();{% endif %}
|
||||
|
||||
// Poll /api/srt_status every 5s to react to live state changes
|
||||
// without opening a second Socket.IO connection (which would inflate
|
||||
// the listener count).
|
||||
setInterval(function () {
|
||||
fetch('/api/srt_status')
|
||||
.then(function (r) { return r.json(); })
|
||||
|
|
|
|||
|
|
@ -1086,15 +1086,8 @@ def listener_get_count():
|
|||
# === MediaMTX webhook — SRT publish / unpublish events ===
|
||||
|
||||
def _listener_template_context() -> dict:
|
||||
"""Return Jinja2 template context for listener.html.
|
||||
|
||||
Keys:
|
||||
live – True when the SRT stream is currently active.
|
||||
hls_url – MediaMTX HLS playlist URL for the video player.
|
||||
"""
|
||||
return {
|
||||
'live': _srt_state['active'],
|
||||
'hls_url': _MEDIAMTX_HLS_URL,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue