Player: Support nginx-http-flv-module stream url. (#3305)

This commit is contained in:
Winlin
2022-12-13 21:03:44 +08:00
committed by GitHub
parent 476a32d417
commit c39edf4788

View File

@@ -188,22 +188,6 @@
return;
}
// Start play HTTP-FLV.
if (r.stream.indexOf('.flv') > 0) {
if (!mpegts.getFeatureList().mseLivePlayback) {
hide_for_error();
return;
}
show_for_ok();
flvPlayer = mpegts.createPlayer({type: 'flv', url: r.url, isLive: true});
flvPlayer.attachMediaElement(document.getElementById('video_player'));
flvPlayer.load();
flvPlayer.play();
return;
}
// Start play HTTP-TS.
if (r.stream.indexOf('.ts') > 0) {
if (!mpegts.getFeatureList().mseLivePlayback) {
@@ -244,6 +228,27 @@
return;
}
// Start play HTTP-FLV.
let isFlv = r.stream.indexOf('.flv') > 0;
// Compatible with NGINX-HTTP-FLV module, see https://github.com/winshining/nginx-http-flv-module and the stream
// url without .flv, such as:
// http://localhost:8080/live?app=live&stream=livestream
isFlv = isFlv || r.stream && r.url.indexOf('http') === 0;
if (isFlv) {
if (!mpegts.getFeatureList().mseLivePlayback) {
hide_for_error();
return;
}
show_for_ok();
flvPlayer = mpegts.createPlayer({type: 'flv', url: r.url, isLive: true});
flvPlayer.attachMediaElement(document.getElementById('video_player'));
flvPlayer.load();
flvPlayer.play();
return;
}
console.error('不支持的URL', r.url, r);
$('#video_player').hide();
};