mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Fix update media end time
This commit is contained in:
10
clapper_src/controls.js
vendored
10
clapper_src/controls.js
vendored
@@ -371,14 +371,10 @@ class ClapperControls extends Gtk.Box
|
||||
|
||||
_onPositionScaleValueChanged(scale)
|
||||
{
|
||||
let value = Math.round(scale.get_value());
|
||||
this.updateElapsedLabel(value);
|
||||
let positionSeconds = Math.round(scale.get_value());
|
||||
|
||||
if(this.currentPosition === value || this.isPositionSeeking)
|
||||
return;
|
||||
|
||||
let { player } = this.get_ancestor(Gtk.Grid);
|
||||
player.seek_seconds(value);
|
||||
this.currentPosition = positionSeconds;
|
||||
this.updateElapsedLabel(positionSeconds);
|
||||
}
|
||||
|
||||
_onVolumeScaleValueChanged(scale)
|
||||
|
@@ -344,6 +344,9 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||
let nextUpdate = clapperWidget.updateTime();
|
||||
|
||||
if(nextUpdate === null)
|
||||
return;
|
||||
|
||||
this._updateTimeTimeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, nextUpdate, () => {
|
||||
this._updateTimeTimeout = null;
|
||||
|
||||
@@ -370,14 +373,15 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
{
|
||||
this.state = state;
|
||||
|
||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||
if(!clapperWidget) return;
|
||||
|
||||
if(!this.seek_done && this.state !== GstPlayer.PlayerState.BUFFERING) {
|
||||
clapperWidget.updateTime();
|
||||
this.seek_done = true;
|
||||
debug('seeking finished');
|
||||
}
|
||||
|
||||
let clapperWidget = this.widget.get_ancestor(Gtk.Grid);
|
||||
if(!clapperWidget) return;
|
||||
|
||||
clapperWidget._onPlayerStateChanged(player, state);
|
||||
}
|
||||
|
||||
@@ -468,7 +472,9 @@ class ClapperPlayer extends GstPlayer.Player
|
||||
break;
|
||||
case Gdk.KEY_Right:
|
||||
case Gdk.KEY_Left:
|
||||
value = clapperWidget.controls.positionScale.get_value();
|
||||
value = Math.round(
|
||||
clapperWidget.controls.positionScale.get_value()
|
||||
);
|
||||
this.seek_seconds(value);
|
||||
this._setHideControlsTimeout();
|
||||
clapperWidget.controls.isPositionSeeking = false;
|
||||
|
@@ -145,15 +145,16 @@ class ClapperRevealerTop extends CustomRevealer
|
||||
setTimes(currTime, endTime)
|
||||
{
|
||||
let now = currTime.format(this.timeFormat);
|
||||
let end = `Ends at: ${endTime.format(this.timeFormat)}`;
|
||||
let end = endTime.format(this.timeFormat);
|
||||
let endText = `Ends at: ${end}`;
|
||||
|
||||
this.currentTime.set_label(now);
|
||||
this.endTime.set_label(end);
|
||||
this.endTime.set_label(endText);
|
||||
|
||||
/* Make sure that next timeout is always run after clock changes,
|
||||
* by delaying it for additional few milliseconds */
|
||||
let nextUpdate = 60002 - parseInt(currTime.get_seconds() * 1000);
|
||||
debug(`updated current time: ${now}`);
|
||||
debug(`updated current time: ${now}, ends at: ${end}`);
|
||||
|
||||
return nextUpdate;
|
||||
}
|
||||
|
@@ -223,6 +223,9 @@ var Widget = GObject.registerClass({
|
||||
|
||||
updateTime()
|
||||
{
|
||||
if(!this.revealerTop.visible)
|
||||
return null;
|
||||
|
||||
let currTime = GLib.DateTime.new_now_local();
|
||||
let endTime = currTime.add_seconds(
|
||||
this.controls.positionAdjustment.get_upper() - this.controls.currentPosition
|
||||
@@ -338,9 +341,8 @@ var Widget = GObject.registerClass({
|
||||
{
|
||||
if(
|
||||
!this.isSeekable
|
||||
|| !player.seek_done
|
||||
|| this.controls.isPositionSeeking
|
||||
|| player.state === GstPlayer.PlayerState.BUFFERING
|
||||
|| !player.seek_done
|
||||
)
|
||||
return;
|
||||
|
||||
@@ -348,7 +350,6 @@ var Widget = GObject.registerClass({
|
||||
if(positionSeconds === this.controls.currentPosition)
|
||||
return;
|
||||
|
||||
this.controls.currentPosition = positionSeconds;
|
||||
this.controls.positionScale.set_value(positionSeconds);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user