AirenSoft / OvenPlayer

OvenPlayer is JavaScript-based LLHLS and WebRTC Player for OvenMediaEngine.
https://OvenMediaEngine.com/ovenplayer
MIT License
497 stars 124 forks source link

Dynamically change HLS parameters #422

Open ValentinDoche opened 2 months ago

ValentinDoche commented 2 months ago

Hello everyone,

I'm looking for a way to dynamically change the liveSyncDuration parameter.

I have a websocket that sends a liveSyncDuration value and I'm looking for a way to put it in my ovenplayer.

Thanks to all

SangwonOh commented 2 months ago

@ValentinDoche Hi. This little hack will help you.

let myHls = null;

// https://airensoft.gitbook.io/ovenplayer/api-reference/events#on-hlsprepared
// Get an hlsjs instance from OvenPlayer.
player.on('hlsPrepared', function (hls) {
    myHls = hls;
});

// If you change the config value of hlsjs, it will be applied in real time.
yourWebSocket.addEventListener("message", (event) => {
    myHls.config.liveSyncDuration = 2;
});