summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorZaggy1024 <zaggy1024@gmail.com>2023-04-12 00:30:58 -0500
committerSam Atkins <atkinssj@gmail.com>2023-04-14 12:05:52 +0100
commit4df9ef487d14786349ee935e4d814d65921c94a3 (patch)
tree992cf15d1916708de64a2da6e56f189a79167383 /Userland/Applications
parent79779aff18cb55bb3d61a9dcc2eba3d638c80953 (diff)
downloadserenity-4df9ef487d14786349ee935e4d814d65921c94a3.zip
VideoPlayer: Use rounded seconds for the timestamp label
Previously, the time would read "00:00:01" when the timestamp was merely 1 millisecond past the start of the video. If a video does not start with a sample at timestamp 0, then, seeking to the start would display that text rather than "00:00:00".
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
index 03510ecf4c..81df461887 100644
--- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
+++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/NumberFormat.h>
#include <LibFileSystemAccessClient/Client.h>
#include <LibGUI/Action.h>
#include <LibGUI/BoxLayout.h>
@@ -249,8 +250,8 @@ void VideoPlayerWidget::set_time_label(Time timestamp)
{
StringBuilder string_builder;
auto append_time = [&](Time time) {
- auto seconds = time.to_seconds();
- string_builder.appendff("{:02}:{:02}:{:02}", seconds / 3600, seconds / 60, seconds % 60);
+ auto seconds = (time.to_milliseconds() + 500) / 1000;
+ string_builder.append(human_readable_digital_time(seconds));
};
append_time(timestamp);
@@ -259,7 +260,7 @@ void VideoPlayerWidget::set_time_label(Time timestamp)
string_builder.append(" / "sv);
append_time(m_playback_manager->duration());
} else {
- string_builder.append(" / --:--:--.---"sv);
+ string_builder.append(" / --:--:--"sv);
}
m_timestamp_label->set_text(string_builder.string_view());