From 83b3a862e35f11a7931046dc652f756a4e6456d2 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Wed, 16 Oct 2024 21:26:31 +0200 Subject: [PATCH] use gst time constants no more 1000000000000000000000000000000 in code --- src/playbin.vala | 2 +- src/ui/window.vala | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/playbin.vala b/src/playbin.vala index 65dc7ed..121fa19 100644 --- a/src/playbin.vala +++ b/src/playbin.vala @@ -243,7 +243,7 @@ class Playbin : GLib.Object { this.current_song = song; this.position = 0; - this.duration = song.duration * 1000000000 - 1; + this.duration = song.duration * Gst.SECOND - 1; this.now_playing (false); } diff --git a/src/ui/window.vala b/src/ui/window.vala index 7f141ce..862670a 100644 --- a/src/ui/window.vala +++ b/src/ui/window.vala @@ -134,8 +134,7 @@ class Ui.Window : Adw.ApplicationWindow { // treat 1 nanosecond as a sentinel value return "-"; } - int64 ms = ns / 1000000; - int s = (int) (ms / 1000); + int s = (int) (ns / Gst.SECOND); return "%02d:%02d".printf (s/60, s%60); } @@ -203,14 +202,14 @@ class Ui.Window : Adw.ApplicationWindow { [GtkCallback] private void seek_backward () { // 10 seconds - int64 new_position = position - (int64)10 * 1000 * 1000000; + int64 new_position = position - 10 * Gst.SECOND; if (new_position < 0) new_position = 0; this.seek_impl (new_position); } [GtkCallback] private void seek_forward () { // 10 seconds - int64 new_position = position + (int64)10 * 1000 * 1000000; + int64 new_position = position + 10 * Gst.SECOND; if (new_position > this.playbin.duration) new_position = this.playbin.duration; this.seek_impl (new_position); }