Fix HLS proxy and player functionality (first working version)
This commit is contained in:
+22
-9
@@ -33,21 +33,34 @@
|
||||
<a href="/" class="back-link">← Back</a>
|
||||
<h1>{{ title }}</h1>
|
||||
<div class="video-container">
|
||||
<video controls>
|
||||
Your browser does not support HLS.
|
||||
<video controls id="video">
|
||||
Your browser does not support video playback.
|
||||
</video>
|
||||
</div>
|
||||
<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
|
||||
<script>
|
||||
const video = document.querySelector('video');
|
||||
const video = document.getElementById('video');
|
||||
const hlsUrl = {{ proxy_hls_url | tojson }};
|
||||
const directUrl = {{ direct_url | tojson }};
|
||||
|
||||
if (Hls.isSupported()) {
|
||||
const hls = new Hls();
|
||||
hls.loadSource(hlsUrl);
|
||||
hls.attachMedia(video);
|
||||
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = hlsUrl;
|
||||
if (hlsUrl && hlsUrl !== 'null') {
|
||||
if (Hls.isSupported()) {
|
||||
const hls = new Hls();
|
||||
hls.loadSource(hlsUrl);
|
||||
hls.attachMedia(video);
|
||||
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||
video.src = hlsUrl;
|
||||
} else {
|
||||
loadDirectUrl();
|
||||
}
|
||||
} else if (directUrl && directUrl !== 'null') {
|
||||
loadDirectUrl();
|
||||
}
|
||||
|
||||
function loadDirectUrl() {
|
||||
if (directUrl && directUrl !== 'null') {
|
||||
video.src = directUrl;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user