From 9799783ee503a5dcd32ce4a9f32303867d30b2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Sat, 17 Apr 2021 13:08:12 +0200 Subject: [PATCH] Use Gst.(M)SECOND constants instead of numbers It makes code easier to read --- src/player.js | 6 +++--- src/playerBase.js | 4 ++-- src/widget.js | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/player.js b/src/player.js index 261a937f..618e42ad 100644 --- a/src/player.js +++ b/src/player.js @@ -183,7 +183,7 @@ class ClapperPlayer extends PlayerBase seek_seconds(seconds) { - this.seek(seconds * 1000000000); + this.seek(seconds * Gst.SECOND); } seek_chapter(seconds) @@ -324,8 +324,8 @@ class ClapperPlayer extends PlayerBase let resumeInfo = {}; if(playlistItem.isLocalFile && settings.get_boolean('resume-enabled')) { - const resumeTime = Math.floor(this.position / 1000000000); - const resumeDuration = this.duration / 1000000000; + const resumeTime = Math.floor(this.position / Gst.SECOND); + const resumeDuration = this.duration / Gst.SECOND; /* Do not save resume info when video is very short, * just started or almost finished */ diff --git a/src/playerBase.js b/src/playerBase.js index 7afe5b19..98a2db6a 100644 --- a/src/playerBase.js +++ b/src/playerBase.js @@ -164,12 +164,12 @@ class ClapperPlayerBase extends GstClapper.Clapper root[action + '_css_class'](gpuClass); break; case 'audio-offset': - value = Math.round(settings.get_double(key) * -1000000); + value = Math.round(settings.get_double(key) * -Gst.MSECOND); this.set_audio_video_offset(value); debug(`set audio-video offset: ${value}`); break; case 'subtitle-offset': - value = Math.round(settings.get_double(key) * -1000000); + value = Math.round(settings.get_double(key) * -Gst.MSECOND); this.set_subtitle_video_offset(value); debug(`set subtitle-video offset: ${value}`); break; diff --git a/src/widget.js b/src/widget.js index f32ea72e..94f14e4b 100644 --- a/src/widget.js +++ b/src/widget.js @@ -371,7 +371,7 @@ class ClapperWidget extends Gtk.Grid return; } - const pos = Math.floor(start / 1000000) / 1000; + const pos = Math.floor(start / Gst.MSECOND) / 1000; const tags = subentry.get_tags(); this.controls.positionScale.add_mark(pos, Gtk.PositionType.TOP, null); @@ -467,7 +467,7 @@ class ClapperWidget extends Gtk.Grid _onPlayerDurationChanged(player, duration) { - const durationSeconds = duration / 1000000000; + const durationSeconds = duration / Gst.SECOND; const durationFloor = Math.floor(durationSeconds); /* Sometimes GstPlayer might re-emit @@ -515,7 +515,7 @@ class ClapperWidget extends Gtk.Grid ) return; - const positionSeconds = Math.round(position / 1000000000); + const positionSeconds = Math.round(position / Gst.SECOND); if(positionSeconds === this.controls.currentPosition) return;