Home > Software engineering >  React JW player how to get current duration of video?
React JW player how to get current duration of video?

Time:05-21

I am using React JW player.

My component

                    <ReactJWPlayer
                      playerId="id"
                      playerScript="https://content.jwplatform.com/libraries/xxxx.js"
                      playlist={{"My JSON"}}
                    />

This is working well. I need to get the current duration of the playing video. How can I do that in reactjs?

CodePudding user response:

You can access "raw" JW player by doing

<ReactJWPlayer playerId="id" ...

let playerInstance = window.jwplayer('id');

To get current position of JW Player do

playerInstance.getPosition();

Expose JW Player instance | JW Player .getPosition()

  • Related