Trouble with current bitrate js - switchingChangeComplete

Hi!
I’m trying to get the bitrate value of a video when a user change its quality.
I’m using:

kpd.kBind('switchingChangeComplete', function (newBitrate) {
   console.log(newBitrate);
});

or

kpd.kBind('switchingChangeComplete', function () {
   console.log(arguments[0]);
});

and it seems like the value that this function returns, is the previous one (If I had 360p selected, when switching to 480p the triggered event reports the bitrate corresponding to 360p quality)
Is there any solution for this? Am I triggering the wrong event?

Also, I experimented that in chrome console, the method kdp.currentBitrate is working perfectly, returning the right value, but when I put it on the js script, the return value is undefined.

Can you help me with this?

Thank you so much for your help.

Hi @carlotagd

I haven’t seen the full context of the code, however, it could be that the kdp parameter was not defined, which is a bit more elaborated in the following article:

https://vpaas.kaltura.com/documentation/Web-Video-Player/Kaltura-Media-Player-API.html#obtaining-a-reference-to-the-embedded-player

In addition, the following script is an example of somthing that you may want to achive:

kWidget.addReadyCallback( function( playerId ){
    var kdp = document.getElementById( 'kaltura_player' );
    kdp.kBind( 'bitrateChange', function(data){
        // Seek to 30 seconds from the start of the video
        console.log(data);
    })
});

Hope it suits your needs.
Cheers.