mdn/content

HTMLMediaElement.currentTime: precision seems different from Date.now

オープン

#35,239 opened on 2024/07/30

 (3 件のコメント) (0 件のリアクション) (0 人の担当者)Markdown (23,229 件のフォーク)batch import
Content:WebAPIhelp wanted

Repository metrics

Stars
 (10,950 個のスター)
PR merge metrics
 (PR metrics pending)

説明

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!

コントリビューターガイド