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