Use cubic scale for volume. Fixes #21

Volume sliders should usually adjust volume using cubic scale. This also changes max volume to 150% which should be louder than previous value anyway.
This commit is contained in:
Rafostar
2020-11-30 09:26:27 +01:00
parent bc5aa45a8f
commit e7ad0143a5
4 changed files with 67 additions and 34 deletions

View File

@@ -66,7 +66,9 @@ var Widget = GObject.registerClass({
this.player = new Player();
this.player.connect('position-updated', this._onPlayerPositionUpdated.bind(this));
this.player.connect('duration-changed', this._onPlayerDurationChanged.bind(this));
this.player.connect('volume-changed', this._onPlayerVolumeChanged.bind(this));
/* FIXME: re-enable once ported to new GstPlayer API with messages bus */
//this.player.pipeline.connect('notify::volume', this._onPlayerVolumeChanged.bind(this));
this.overlay.set_child(this.player.widget);
this.overlay.add_overlay(this.revealerTop);
@@ -462,15 +464,18 @@ var Widget = GObject.registerClass({
_onPlayerVolumeChanged(player)
{
let volume = player.get_volume();
/* FIXME: This check should not be needed, GstPlayer should not
* emit 'volume-changed' with the same values. It needs to be
* fixed inside GStreamer GstPlayer API */
let volume = Number(player.get_volume().toFixed(2));
* emit 'volume-changed' with the same values, but it does. */
if(volume === this.controls.currentVolume)
return;
/* Once above is fixed in GstPlayer, remove this var too */
this.controls.currentVolume = volume;
this.controls.volumeScale.set_value(volume);
let cubicVolume = Misc.getCubicValue(volume);
this.controls._updateVolumeButtonIcon(cubicVolume);
}
_onStateNotify(toplevel)