Skip to content

Commit 6b51c3c

Browse files
trflynn89linusg
authored andcommitted
LibWeb: Report HTMLMediaElement duration with sub-second accuracy
We currently use Time::to_seconds() to report a video's duration. The video, however, may have a sub-second duration. For example, the video used by the video test page is 12.05 seconds long.
1 parent 2ef4a51 commit 6b51c3c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Userland/Libraries/LibWeb/HTML/HTMLMediaElement.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,8 @@ WebIDL::ExceptionOr<void> HTMLMediaElement::process_media_data(Function<void()>
676676
// 4. Update the duration attribute with the time of the last frame of the resource, if known, on the media timeline established above. If it is
677677
// not known (e.g. a stream that is in principle infinite), update the duration attribute to the value positive Infinity.
678678
// FIXME: Handle unbounded media resources.
679-
set_duration(static_cast<double>(video_track->duration().to_seconds()));
679+
auto duration = static_cast<double>(video_track->duration().to_milliseconds());
680+
set_duration(duration / 1000.0);
680681

681682
// 5. For video elements, set the videoWidth and videoHeight attributes, and queue a media element task given the media element to fire an event
682683
// named resize at the media element.

0 commit comments

Comments
 (0)