mdn / content

The content behind MDN Web Docs
https://developer.mozilla.org
Other
9.19k stars 22.48k forks source link

HTMLMediaElement.currentTime: precision seems different from Date.now #35239

Open andrewlavens opened 3 months ago

andrewlavens commented 3 months ago

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!

SheepTester commented 3 months ago

what browser are you observing this on? it is noted later in the section that currentTime may get rounded, though at least on firefox it should be rounded the same way as Date.now

andrewlavens commented 3 months ago

I think that particular example was from Chrome, but I'll generate some from Firefox and post that too.

andrewlavens commented 3 months ago

Sorry for the delay. Here's a lot of output from Firefox. The first column is from currentTime and the second is from a call to Date() and some formatting. The audio is a WAV noise file contained within an

One section from the output: 4.432698 9:21:25.098 4.432698 9:21:25.106 4.432698 9:21:25.121 4.432698 9:21:25.139

The output: 0.503922 9:21:21.186 0.503922 9:21:21.207 0.503922 9:21:21.213 0.551678 9:21:21.225 0.551678 9:21:21.240 0.596848 9:21:21.276 0.596848 9:21:21.292 0.596848 9:21:21.307 0.644104 9:21:21.323 0.644104 9:21:21.339 0.644104 9:21:21.356 0.692199 9:21:21.373 0.692199 9:21:21.388 0.692199 9:21:21.407 0.739478 9:21:21.423 0.739478 9:21:21.440 0.787369 9:21:21.457 0.787369 9:21:21.490 0.835306 9:21:21.508 0.835306 9:21:21.527 0.835306 9:21:21.540 0.884376 9:21:21.557 0.884376 9:21:21.572 0.884376 9:21:21.589 0.931564 9:21:21.607 0.931564 9:21:21.623 0.931564 9:21:21.640 0.978367 9:21:21.673 0.978367 9:21:21.689 1.024353 9:21:21.706 1.024353 9:21:21.724 1.072653 9:21:21.740 1.072653 9:21:21.759 1.120294 9:21:21.789 1.120294 9:21:21.808 1.120294 9:21:21.823 1.167392 9:21:21.840 1.167392 9:21:21.858 1.213356 9:21:21.889 1.213356 9:21:21.907 1.213356 9:21:21.925 1.26297 9:21:21.940 1.26297 9:21:21.956 1.26297 9:21:21.973 1.309319 9:21:21.988 1.309319 9:21:22.008 1.309319 9:21:22.023 1.405986 9:21:22.115 1.453356 9:21:22.140 1.453356 9:21:22.157 1.501383 9:21:22.180 1.501383 9:21:22.197 1.501383 9:21:22.206 1.549251 9:21:22.222 1.549251 9:21:22.239 1.549251 9:21:22.258 1.598684 9:21:22.290 1.598684 9:21:22.306 1.644988 9:21:22.330 1.644988 9:21:22.356 1.690657 9:21:22.391 1.737324 9:21:22.406 1.737324 9:21:22.422 1.737324 9:21:22.438 1.784376 9:21:22.455 1.784376 9:21:22.472 1.784376 9:21:22.491 1.833174 9:21:22.508 1.833174 9:21:22.522 1.927981 9:21:22.604 1.927981 9:21:22.622 1.927981 9:21:22.638 1.975442 9:21:22.657 1.975442 9:21:22.678 2.022698 9:21:22.693 2.022698 9:21:22.707 2.022698 9:21:22.722 2.068843 9:21:22.738 2.068843 9:21:22.777 2.114058 9:21:22.788 2.114058 9:21:22.807 2.114058 9:21:22.823 2.163129 9:21:22.839 2.163129 9:21:22.857 2.163129 9:21:22.874 2.2156 9:21:22.891 2.2156 9:21:22.921 2.25687 9:21:22.940 2.25687 9:21:22.961 2.303854 9:21:22.973 2.303854 9:21:22.991 2.303854 9:21:23.005 2.351836 9:21:23.022 2.351836 9:21:23.038 2.351836 9:21:23.054 2.399047 9:21:23.076 2.399047 9:21:23.103 2.446984 9:21:23.149 2.446984 9:21:23.158 2.495079 9:21:23.181 2.542947 9:21:23.211 2.542947 9:21:23.222 2.542947 9:21:23.257 2.593174 9:21:23.273 2.593174 9:21:23.291 2.638412 9:21:23.321 2.638412 9:21:23.331 2.685963 9:21:23.364 2.685963 9:21:23.373 2.685963 9:21:23.397 2.733038 9:21:23.408 2.733038 9:21:23.429 2.782063 9:21:23.451 2.782063 9:21:23.459 2.782063 9:21:23.474 2.782063 9:21:23.489 2.824965 9:21:23.508 2.824965 9:21:23.524 2.871995 9:21:23.539 2.871995 9:21:23.573 2.919115 9:21:23.589 2.919115 9:21:23.617 2.919115 9:21:23.630 3.014421 9:21:23.718 3.061859 9:21:23.740 3.061859 9:21:23.758 3.109319 9:21:23.777 3.109319 9:21:23.792 3.109319 9:21:23.807 3.109319 9:21:23.822 3.159501 9:21:23.838 3.159501 9:21:23.858 3.205487 9:21:23.875 3.205487 9:21:23.890 3.253197 9:21:23.921 3.300498 9:21:23.973 3.300498 9:21:23.988 3.348276 9:21:24.018 3.395283 9:21:24.071 3.395283 9:21:24.074 3.395283 9:21:24.089 3.395283 9:21:24.105 3.44229 9:21:24.126 3.44229 9:21:24.140 3.44229 9:21:24.155 3.492358 9:21:24.172 3.492358 9:21:24.189 3.538208 9:21:24.222 3.538208 9:21:24.239 3.586326 9:21:24.255 3.586326 9:21:24.272 3.586326 9:21:24.288 3.632789 9:21:24.305 3.632789 9:21:24.322 3.632789 9:21:24.340 3.680997 9:21:24.355 3.680997 9:21:24.371 3.680997 9:21:24.388 3.727709 9:21:24.405 3.727709 9:21:24.421 3.727709 9:21:24.441 3.776961 9:21:24.455 3.776961 9:21:24.471 3.819591 9:21:24.488 3.819591 9:21:24.505 3.819591 9:21:24.521 3.865623 9:21:24.539 3.865623 9:21:24.555 3.865623 9:21:24.571 3.914081 9:21:24.588 3.914081 9:21:24.605 3.914081 9:21:24.622 3.960816 9:21:24.640 3.960816 9:21:24.655 3.960816 9:21:24.671 4.009523 9:21:24.688 4.009523 9:21:24.705 4.009523 9:21:24.722 4.056643 9:21:24.740 4.056643 9:21:24.755 4.103673 9:21:24.771 4.103673 9:21:24.788 4.103673 9:21:24.808 4.15077 9:21:24.822 4.15077 9:21:24.844 4.15077 9:21:24.856 4.198548 9:21:24.871 4.198548 9:21:24.890 4.198548 9:21:24.906 4.244625 9:21:24.922 4.244625 9:21:24.940 4.244625 9:21:24.956 4.295351 9:21:24.972 4.295351 9:21:24.994 4.338526 9:21:25.005 4.338526 9:21:25.022 4.338526 9:21:25.039 4.385646 9:21:25.055 4.385646 9:21:25.072 4.432698 9:21:25.098 4.432698 9:21:25.106 4.432698 9:21:25.121 4.432698 9:21:25.139 4.479727 9:21:25.158 4.479727 9:21:25.171 4.526689 9:21:25.206 4.526689 9:21:25.221 4.526689 9:21:25.240 4.577641 9:21:25.259 4.621541 9:21:25.290 4.621541 9:21:25.306 4.621541 9:21:25.322 4.66873 9:21:25.338 4.763605 9:21:25.466 5.999319 9:21:26.675 6.569342 9:21:27.234 7.518412 9:21:28.219 8.601904 9:21:29.291