mdn/content

HTMLMediaElement.currentTime: precision seems different from Date.now

Open

#35.239 aperta il 30 lug 2024

Vedi su GitHub
 (3 commenti) (0 reazioni) (0 assegnatari)Markdown (22.427 fork)batch import
Content:WebAPIhelp wanted

Metriche repository

Star
 (8900 star)
Metriche merge PR
 (Merge medio 7g 3h) (147 PR mergiate in 30 g)

Descrizione

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/currentTime

What specific section or headline is this issue about?

Value

What information was incorrect, unhelpful, or incomplete?

"A double-precision floating-point value indicating the current playback time in seconds."

What did you expect to see?

I'm wondering if there is something that should be added to that definition. I've been looking a a slider that uses onChange to record the currentTime and the date from Date.now. Interestingly, sometimes the currentTime value doesn't change even though Date.now has changed. Given that currentTime is shown to six decimal places this seems unlikely. I've been able to replicate this in different browsers and sliders so I suspect I'm looking at 'feature' rather than 'bug' but can't work out what it is. Is currentTime the time of the most recent 'chunk' of audio (albeit a small one)?

Do you have any supporting links, references, or citations?

Here's a quick grab from the log showing currentTime on the left and Date.now() on the right formatted as h:mm:ss.000. The second and third entries have the same currentTime. 4.550919 9:38:10.768 4.558815 9:38:10.776 4.558815 9:38:10.785 4.566465 9:38:10.792

Do you have anything more you want to share?

Apologies for being such a pedant!

Guida contributor