Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spotify's "player state" is available in the editor, but in a packaged app, it gets only "«constant ****kPSP»"

Here's a testing code:

tell application "Spotify"
    set playerState to player state as string
end tell
display dialog playerState

Works fine from the AppleScript editor. However, when I export my script as an app, all I get is this: enter image description here

Why is this happening?

like image 631
Artem Gordinsky Avatar asked Nov 15 '25 16:11

Artem Gordinsky


1 Answers

It seems that Spotify is not coercing the constant into a string. Since the editor can't coerce it from an applet as it does when you are running the script in AppleScript Editor, the four-letter constant code is returned. Since you can't test the player state's value as a string, try to test it against the constants themselves.

property spotPause : «constant ****kPSp»
property spotPlay : «constant ****kPSP»

tell application "Spotify" to set playerState to player state

if playerState = spotPause then
    display dialog "paused"
else if playerState = spotPlay then
    display dialog "playing"
end if
like image 131
adayzdone Avatar answered Nov 17 '25 07:11

adayzdone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!