1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -188,22 +188,6 @@
return; 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. // Start play HTTP-TS.
if (r.stream.indexOf('.ts') > 0) { if (r.stream.indexOf('.ts') > 0) {
if (!mpegts.getFeatureList().mseLivePlayback) { if (!mpegts.getFeatureList().mseLivePlayback) {
@ -244,6 +228,27 @@
return; 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); console.error('不支持的URL', r.url, r);
$('#video_player').hide(); $('#video_player').hide();
}; };