Jonathan M. Jonathan M. - 1 month ago 14
AppleScript Question

Spotify - sound volume - AppleScript API

I have try many, many scenario to make a script that will raise the volume with no success. here example:

tell application "System Events"
set MyList to (name of every process)
end tell
if (MyList contains "Spotify") is true then

tell application "Spotify"
set volcheck to get sound volume
set volcheck to (volcheck + 10)
set sound volume to volcheck
end tell

end if


or :

tell application "System Events"
set MyList to (name of every process)
end tell

if (MyList contains "Spotify") is true then

tell application "Spotify"
set sound volume to (sound volume + 10)
end tell

end if


To debug I have use the commande "SAY sound volume" after different step and I discover that the value is stuck on the same value he get the first time. The only way it will "reset" it is by pressing pause/play. Every time I pause/play "sound volume" get the new value and the modification work once until i pause/play again.

Here i ask for help : https://forum.keyboardmaestro.com/

and they said that i should report this to spotify. On spotify i was looking where i should report this and it saying for none developer to post here. so here i'm.

SO my question is :

I'm a the right place to talk about this bug ?

and

Is there someone who have a solution ?

Answer

It looks like you've asked this question elsewhere and may have found the answer: this was broken in some versions of Spotify, but what you had was basically about right.

I've extended it below, as (at least in v1.0.20.94.g8f8543b3) the volume wraps to 0 if you set it to a value above 100. Similarly it will wrap around to 100 if you try to set it below 0.

tell application "Spotify"
    set currentvol to get sound volume
    -- volume wraps at 100 to 0
    if currentvol > 90 then
        set sound volume to 100
    else
        set sound volume to currentvol + 10
    end if
end tell