Browse Source

hls muxer: prefer hls.js over native HLS

pull/956/head v0.18.3
aler9 4 years ago
parent
commit
b6b99b142a
  1. 23
      internal/core/hls_muxer.go

23
internal/core/hls_muxer.go

@ -55,16 +55,10 @@ html, body {
const create = () => { const create = () => {
const video = document.getElementById('video'); const video = document.getElementById('video');
if (video.canPlayType('application/vnd.apple.mpegurl')) { // always prefer hls.js over native HLS.
// since it's not possible to detect timeout errors in iOS, // this is because some Android versions support native HLS
// wait for the playlist to be available before starting the stream // but doesn't support fMP4s.
fetch('stream.m3u8') if (Hls.isSupported()) {
.then(() => {
video.src = 'index.m3u8';
video.play();
});
} else {
const hls = new Hls({ const hls = new Hls({
progressive: true, progressive: true,
liveSyncDurationCount: 3, liveSyncDurationCount: 3,
@ -83,6 +77,15 @@ const create = () => {
hls.attachMedia(video); hls.attachMedia(video);
video.play(); 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();
});
} }
}; };

Loading…
Cancel
Save