mdn/content

HTMLMediaElement.currentTime: precision seems different from Date.now

Open

#35.239 aberto em 30 de jul. de 2024

Ver no GitHub
 (3 comments) (0 reactions) (0 assignees)Markdown (22.427 forks)batch import
Content:WebAPIhelp wanted

Métricas do repositório

Stars
 (8.900 stars)
Métricas de merge de PR
 (Mesclagem média 7d 3h) (147 fundiu PRs em 30d)

Description

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!

Guia do colaborador