AirenSoft / OvenPlayer

OvenPlayer is JavaScript-based LLHLS and WebRTC Player for OvenMediaEngine.
https://airensoft.com/ome.html
MIT License
508 stars 126 forks source link

Auto refresh causing flickering problem #339

Closed martiankoder closed 8 months ago

martiankoder commented 1 year ago

Hi everyone,

I just followed the code on this post (issue) #132 The solution given in the post helped refresh but the player just flickers. I tried to set the interval to 5 seconds, but it does not help much. It just delays the transition from the text error "Connection with low latency (OME) server failed" to an image of circular play button. It just repeats the transition. This might cause a headache to users. ;) Very annoying. The solution causes a bad problem.

Do you know how to fix it ? Thanks.

The solution given in the post above was: `var ovenPlayer = null;

function loadOvenPlayer () {

if (ovenPlayer) {

    ovenPlayer.remove();
}

ovenPlayer = OvenPlayer.create({/*your_options*/});

// Reload OvenPlayer when error occured.
ovenPlayer.on('error', function () {

    // Wait 1 sec and relaod.
    setTimeout(function () {

        loadOvenPlayer();
    }, 1000)
});

}

loadOvenPlayer();`

bchah commented 1 year ago

Assuming you are using OvenPlayer with OvenMediaEngine, I suggest using the REST API to check if the stream is live before reloading the player. There are also 'bigPlayButton' and 'autoplay' instantiation options for OvenPlayer if you want to change the way the player looks when it appears.

martiankoder commented 1 year ago

Thank you for your reply, The autoPlay is actually autoStart, as stated in the issue #132 by the poster of this issue, autoStart did not help, that's why it was given the solution in the code above. But the code causes flickering. I am not aware of the REST API, can you show it to me, I can't find it. Thank you.

bchah commented 1 year ago

https://airensoft.gitbook.io/ovenmediaengine/rest-api

martiankoder commented 1 year ago

I don't see where indicates that the stream is ready, even if the stream is ready on the input side, the viewers' ovenplayer might have not received the stream yet, or it is not receiving enough data to load and play on the OvenPlayer. Can you give me an example on the client side and server side, how to can get a property or variable indicating the stream is ready to load? Thank you

bchah commented 1 year ago

I periodically send a GET to OME/v1/vhosts/{vhost}/apps/{app}/streams/{stream} which returns 404 if the stream is not live. If you get a 200, the stream is live and you can then call player.load() or player.create()

SangwonOh commented 8 months ago

Thanks for many help bchah!

We are closing the issue due to a long period of inactivity. If further discussion is needed, please reopen the issue.