From b6b99b142ab5019b7786350a6bc23fd0b975d899 Mon Sep 17 00:00:00 2001 From: aler9 <46489434+aler9@users.noreply.github.com> Date: Sat, 30 Apr 2022 23:18:11 +0200 Subject: [PATCH] hls muxer: prefer hls.js over native HLS --- internal/core/hls_muxer.go | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/internal/core/hls_muxer.go b/internal/core/hls_muxer.go index fef336c5..908c065b 100644 --- a/internal/core/hls_muxer.go +++ b/internal/core/hls_muxer.go @@ -55,16 +55,10 @@ html, body { const create = () => { const video = document.getElementById('video'); - if (video.canPlayType('application/vnd.apple.mpegurl')) { - // since it's not possible to detect timeout errors in iOS, - // wait for the playlist to be available before starting the stream - fetch('stream.m3u8') - .then(() => { - video.src = 'index.m3u8'; - video.play(); - }); - - } else { + // always prefer hls.js over native HLS. + // this is because some Android versions support native HLS + // but doesn't support fMP4s. + if (Hls.isSupported()) { const hls = new Hls({ progressive: true, liveSyncDurationCount: 3, @@ -83,6 +77,15 @@ const create = () => { hls.attachMedia(video); video.play(); + + } else if (video.canPlayType('application/vnd.apple.mpegurl')) { + // since it's not possible to detect timeout errors in iOS, + // wait for the playlist to be available before starting the stream + fetch('stream.m3u8') + .then(() => { + video.src = 'index.m3u8'; + video.play(); + }); } };