这是一个测试代码:
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:
为什么会发生这种情况?
Spotify 似乎没有将常量强制转换为字符串。由于编辑器无法像在 AppleScript 编辑器中运行脚本时那样从小程序强制执行它,因此会返回四个字母的常量代码。由于您无法将玩家状态的值作为字符串进行测试,因此请尝试根据常量本身对其进行测试。
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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)