mdn/content

HTMLMediaElement.currentTime: precision seems different from Date.now

Open

#35,239 创建于 2024年7月30日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Markdown (22,427 fork)batch import
Content:WebAPIhelp wanted

仓库指标

Star
 (8,900 star)
PR 合并指标
 (平均合并 7天 3小时) (30 天内合并 147 个 PR)

描述

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!

贡献者指南