'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:

Why is this happening?
Solution 1:[1]
It's better to use this code to obtain the player state. You don't need to know the exact constant values. Works on OS X 10.13
tell application "Spotify"
if player state is playing then
display dialog "Player running"
else if player state is paused then
display dialog "Player paused"
else if player is stopped then
display dialog "Player is stopped"
else
display dialog "Unknow state"
end if
end tell
Solution 2:[2]
I wasn't able to comment adayzdone's answer yet here's an alternative:
if player state is playing or player state is paused then
E.G
if application "Spotify" is running then
tell application "Spotify"
if player state is playing or player state is paused then
set trackID to (get id of current track)
end if
end tell
end if
This atleast worked on Catalina (10.15.7) when working on a Spotify-Applescript project of my own.
The source of the idea came from this thread.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | drizzt.dourden |
| Solution 2 |
