Stream React API


Having started using the React player, I am a bit confused by its API (GitHub - cloudflare/stream-react). The onTimeUpdate, onProgress, and any other “on_” callbacks, return timeStamp in the following format 399201.3000000119. How is one to parse this, as docs do not mention what format this data is in, and it’s not coming straight from the HTML5 video currentTime.



Hi, there! You can access the instance of the player SDK via the streamRef prop, and then read the .currentTime property, which does come from the <video /> element inside the iframe. This value is in seconds. Hope this helps!

Hi kkipp,

Thanks for the reply. That is what I wound up doing. But I’m still perplexed by the unknown time format of the timeStamp. Does anyone, including the author, know what it’s supposed to represent?

Thanks again,

The timestamp is in seconds.

You’re referring to the web standard, but I’m referring to the unknown
format of event.timeStamp in the Stream API, which at 00:06 (six seconds)
displays: 182624.29999999888. My initial post was asking if someone knew
how to convert the strange event.timeStamp into seconds.

const onPlay = (evt: any) => {
console.log(“onPlay evt.timeStamp”, evt.timeStamp);

Ah, I see. This is not related to the video, but is instead part of the standard Event API.