Skip to content

Commit

Permalink
hls muxer: prefer hls.js over native HLS
Browse files Browse the repository at this point in the history
  • Loading branch information
aler9 committed May 10, 2022
1 parent f521049 commit b6b99b1
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions internal/core/hls_muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
});
}
};
Expand Down

0 comments on commit b6b99b1

Please sign in to comment.