Removed the .m3u8 URL requirement and prioritize HLS.js for all browsers

This commit is contained in:
Trevor Mears
2025-12-27 23:28:41 -08:00
parent 79d84aa64b
commit 4ab2128f74
+6 -4
View File
@@ -169,7 +169,8 @@ class VideoPlayer {
this.isUsingProxy = needsProxy; this.isUsingProxy = needsProxy;
const finalUrl = needsProxy ? this.getProxiedUrl(streamUrl) : streamUrl; const finalUrl = needsProxy ? this.getProxiedUrl(streamUrl) : streamUrl;
if (finalUrl.includes('.m3u8') && Hls.isSupported()) { // Priority 1: Use HLS.js for all browsers that support it (Chrome, Firefox, Edge, etc.)
if (Hls.isSupported()) {
this.hls = new Hls(); this.hls = new Hls();
this.hls.loadSource(finalUrl); this.hls.loadSource(finalUrl);
this.hls.attachMedia(this.video); this.hls.attachMedia(this.video);
@@ -191,8 +192,9 @@ class VideoPlayer {
} }
} }
}); });
} else if (this.video.canPlayType('application/vnd.apple.mpegurl')) { } else if (this.video.canPlayType('application/vnd.apple.mpegurl') === 'probably' ||
// Native HLS support (Safari) this.video.canPlayType('application/vnd.apple.mpegurl') === 'maybe') {
// Priority 2: Native HLS support (Safari on iOS/macOS where HLS.js may not work)
this.video.src = finalUrl; this.video.src = finalUrl;
this.video.play().catch(e => { this.video.play().catch(e => {
console.log('Autoplay prevented, trying proxy if CORS error:', e); console.log('Autoplay prevented, trying proxy if CORS error:', e);
@@ -203,7 +205,7 @@ class VideoPlayer {
} }
}); });
} else { } else {
// Try direct playback // Priority 3: Try direct playback for non-HLS streams
this.video.src = finalUrl; this.video.src = finalUrl;
this.video.play().catch(e => console.log('Autoplay prevented:', e)); this.video.play().catch(e => console.log('Autoplay prevented:', e));
} }