First, congratulations for this amazing platform! Just did the switch from custom managed FFmpeg scripts and confs to OvenMediaEngine, this is brilliant...
I found out an uncatched error in the player: when the TURN port from OME in WebRTC is not reacheable, but OME port is reacheable, the player fails with an uncatched error:
"code":511,"message":"Connection with low-latency(OME) terminated unexpectedly.","reason":"Unexpected end of connection."
ovenplayer.js:1 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'id')
at En.e.setCurrentQuality (ovenplayer.js:1:126674)
at Sn.t.load (ovenplayer.js:1:147688)
at Object.<anonymous> (multimedia.js:104:38)
at r (ovenplayer.js:1:49036)
at Ge.t.trigger (ovenplayer.js:1:49232)
at Object.<anonymous> (ovenplayer.js:1:142303)
at r (ovenplayer.js:1:49036)
at Ge.t.trigger (ovenplayer.js:1:49244)
at qe (ovenplayer.js:1:59686)
at M (ovenplayer.js:1:126365)
The player is dead afterwhile and custom event handlers are broken, like fallback to different sources.
Shall I implement a kind of heartbeat mode to check if the player is dead on my side?
For the moment I was using this kind of code, with live sources being in the following order:
[0] webrtc
[1] llhls direct TLS connection
[2] llhls behind nginx proxy on 443 port (for firewalls traversal as last solution)
var options = {
autoStart: true,
autoFallback: true,
controls: true,
// expandFullScreenUI: true,
};
if(muted){
options.mute = 'true';
};
var current_source = 0;
var live_sources = [
//Most perf source
{
type : "webrtc",
file : "wss://" + live_root_url + ":3334" + live_room + "_webrtc",
},
//Direct LLHLS source
{
type : "ll-hls",
file : "https://" + live_root_url + ":3334" + live_room + "_llhls.m3u8",
},
//Proxied LLHLS source
{
type : "ll-hls",
file : "https://" + live_root_url + live_room + "_llhls.m3u8",
}
]
var fallback_sources = [
{
type : fallback_type,
file : fallback_url,
// overrideNative: true,
}
]
if(live_enabled){
options.loop = true;
options.currentProtocolOnly = true;
var last_heartbeat_time = new Date();
var live = true;
var heartbeating = false;
options.sources = live_sources;
}else{
options.sources = fallback_sources;
};
var player = OvenPlayer.create('player_' + div, options);
await player.play();
if(live_enabled){
//Handle fallback on error
player.on("error", async function(e){
console.error("Player error: " + JSON.stringify(e));
if(live_enabled){
//Try other sources
if(current_source < 2){
current_source += 1;
await player.load(live_sources[current_source]);
}else{
//No stream available
//Check if live stream is back (net error)
try {
$.ajax({
url: "https://" + live_root_url + live_room + "_llhls.m3u8",
type: 'GET',
success: async function () {
live = true;
heartbeating = false;
current_source = 0;
await player.load(live_sources);
await player.play();
},
error: async function () {
heartbeating = false;
live = false;
last_heartbeat_time = new Date();
await player.load(fallback_sources);
await player.play();
}
});
} catch (e) {
heartbeating = false;
live = false;
last_heartbeat_time = new Date();
await player.load(fallback_sources);
await player.play();
}
}
}
});
//Handle live back
player.on("time", async function(){
if (live_enabled && live == false && heartbeating == false) {
var now = new Date();
if (now.getTime() > (last_heartbeat_time.getTime() + 15000)) {
heartbeating = true;
//Check if live stream is back
try {
$.ajax({
url: "https://" + live_root_url + live_room + "_llhls.m3u8",
type: 'GET',
success: async function () {
live = true;
last_heartbeat_time = new Date();
heartbeating = false;
current_source = 0;
await player.load(live_sources);
await player.play();
},
error: async function () {
heartbeating = false;
last_heartbeat_time = new Date();
}
});
} catch (e) {
heartbeating = false;
last_heartbeat_time = new Date();
}
}
}
});
}
return player;
Fallback sources are waiting classic videos, to play while the live stream is not on.
By the way, autoFallback seems to be ineffective (might be linked to #328)
Hi,
First, congratulations for this amazing platform! Just did the switch from custom managed FFmpeg scripts and confs to OvenMediaEngine, this is brilliant...
I found out an uncatched error in the player: when the TURN port from OME in WebRTC is not reacheable, but OME port is reacheable, the player fails with an uncatched error:
The player is dead afterwhile and custom event handlers are broken, like fallback to different sources.
Shall I implement a kind of heartbeat mode to check if the player is dead on my side?
For the moment I was using this kind of code, with live sources being in the following order:
[2] llhls behind nginx proxy on 443 port (for firewalls traversal as last solution)
Fallback sources are waiting classic videos, to play while the live stream is not on.
By the way, autoFallback seems to be ineffective (might be linked to #328)