mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-04 22:19:38 +00:00
37_Spotify: smooth volumeDown
git-svn-id: https://svn.fhem.de/fhem/trunk@14434 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
53b12125bd
commit
e1a9f751f3
@ -635,8 +635,22 @@ sub Spotify_volumeStep($$$$) {
|
|||||||
$step = $attr{$name}{volumeStep} if(!defined $step || $step !~ /^[0-9]+$/);
|
$step = $attr{$name}{volumeStep} if(!defined $step || $step !~ /^[0-9]+$/);
|
||||||
$step = 5 if(!defined $step);
|
$step = 5 if(!defined $step);
|
||||||
|
|
||||||
my $nextVolume = min(100, max(0, $hash->{helper}{device_active}{volume_percent} + $step * $direction));
|
my $nextVolume = undef;
|
||||||
$hash->{helper}{device_active}{volume_percent} = $nextVolume;
|
if(defined $device_id) {
|
||||||
|
my @devices = @{$hash->{helper}{devices}};
|
||||||
|
foreach my $device (@devices) {
|
||||||
|
if(defined $device->{id} && $device->{id} eq $device_id) {
|
||||||
|
$nextVolume = min(100, max(0, $device->{volume_percent} + $step * $direction));
|
||||||
|
$device->{volume_percent} = $nextVolume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$nextVolume = min(100, max(0, $hash->{helper}{device_active}{volume_percent} + $step * $direction));
|
||||||
|
$hash->{helper}{device_active}{volume_percent} = $nextVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "could not find device" if(!defined $nextVolume);
|
||||||
|
|
||||||
Spotify_setVolume($hash, 0, $nextVolume, $device_id);
|
Spotify_setVolume($hash, 0, $nextVolume, $device_id);
|
||||||
|
|
||||||
return undef;
|
return undef;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user