mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 07:42:23 +02:00
Merge pull request #44 from Rafostar/gstclapper-volume
API: use cubic volume
This commit is contained in:
5
src/controls.js
vendored
5
src/controls.js
vendored
@@ -489,7 +489,7 @@ class ClapperControls extends Gtk.Box
|
||||
|
||||
const initialVolume = (settings.get_string('volume-initial') === 'custom')
|
||||
? settings.get_int('volume-value') / 100
|
||||
: Misc.getCubicValue(settings.get_double('volume-last'));
|
||||
: settings.get_double('volume-last');
|
||||
|
||||
this.volumeScale.set_value(initialVolume);
|
||||
}
|
||||
@@ -567,10 +567,9 @@ class ClapperControls extends Gtk.Box
|
||||
_onVolumeScaleValueChanged(scale)
|
||||
{
|
||||
const volume = scale.get_value();
|
||||
const linearVolume = Misc.getLinearValue(volume);
|
||||
const { player } = this.get_ancestor(Gtk.Grid);
|
||||
|
||||
player.set_volume(linearVolume);
|
||||
player.set_volume(volume);
|
||||
|
||||
/* FIXME: All of below should be placed in 'volume-changed'
|
||||
* event once we move to message bus API */
|
||||
|
18
src/misc.js
18
src/misc.js
@@ -95,21 +95,3 @@ function getFormattedTime(time, showHours)
|
||||
const parsed = (hours) ? `${hours}:` : '';
|
||||
return parsed + `${minutes}:${seconds}`;
|
||||
}
|
||||
|
||||
function getCubicValue(linearVal)
|
||||
{
|
||||
return GstAudio.StreamVolume.convert_volume(
|
||||
GstAudio.StreamVolumeFormat.LINEAR,
|
||||
GstAudio.StreamVolumeFormat.CUBIC,
|
||||
linearVal
|
||||
);
|
||||
}
|
||||
|
||||
function getLinearValue(cubicVal)
|
||||
{
|
||||
return GstAudio.StreamVolume.convert_volume(
|
||||
GstAudio.StreamVolumeFormat.CUBIC,
|
||||
GstAudio.StreamVolumeFormat.LINEAR,
|
||||
cubicVal
|
||||
);
|
||||
}
|
||||
|
@@ -24,8 +24,6 @@ class ClapperPlayer extends PlayerBase
|
||||
|
||||
this.keyPressCount = 0;
|
||||
|
||||
this._maxVolume = Misc.getLinearValue(Misc.maxVolume);
|
||||
|
||||
const keyController = new Gtk.EventControllerKey();
|
||||
keyController.connect('key-pressed', this._onWidgetKeyPressed.bind(this));
|
||||
keyController.connect('key-released', this._onWidgetKeyReleased.bind(this));
|
||||
@@ -180,17 +178,6 @@ class ClapperPlayer extends PlayerBase
|
||||
this.seek_seconds(seconds);
|
||||
}
|
||||
|
||||
set_volume(volume)
|
||||
{
|
||||
if(volume < 0)
|
||||
volume = 0;
|
||||
else if(volume > this._maxVolume)
|
||||
volume = this._maxVolume;
|
||||
|
||||
super.set_volume(volume);
|
||||
debug(`set player volume: ${volume}`);
|
||||
}
|
||||
|
||||
adjust_position(isIncrease)
|
||||
{
|
||||
this.seek_done = false;
|
||||
@@ -316,7 +303,9 @@ class ClapperPlayer extends PlayerBase
|
||||
}
|
||||
settings.set_string('resume-database', JSON.stringify([resumeInfo]));
|
||||
}
|
||||
settings.set_double('volume-last', this.volume);
|
||||
const volume = this.volume;
|
||||
debug(`saving last volume: ${volume}`);
|
||||
settings.set_double('volume-last', volume);
|
||||
|
||||
clapperWidget.controls._onCloseRequest();
|
||||
}
|
||||
|
@@ -530,7 +530,7 @@ class ClapperWidget extends Gtk.Grid
|
||||
|
||||
_onPlayerVolumeChanged(player)
|
||||
{
|
||||
const volume = player.get_volume();
|
||||
const volume = player.volume;
|
||||
|
||||
/* FIXME: This check should not be needed, GstPlayer should not
|
||||
* emit 'volume-changed' with the same values, but it does. */
|
||||
@@ -540,8 +540,7 @@ class ClapperWidget extends Gtk.Grid
|
||||
/* Once above is fixed in GstPlayer, remove this var too */
|
||||
this.controls.currentVolume = volume;
|
||||
|
||||
const cubicVolume = Misc.getCubicValue(volume);
|
||||
this.controls._updateVolumeButtonIcon(cubicVolume);
|
||||
this.controls._updateVolumeButtonIcon(volume);
|
||||
}
|
||||
|
||||
_onStateNotify(toplevel)
|
||||
|
Reference in New Issue
Block a user