Spotify 的“播放器状态"在编辑器中可用,但在打包的应用程序中,它只获得“«constant ****kPSP»"; [英] Spotify's "player state" is available in the editor, but in a packaged app, it gets only "«constant ****kPSP»"

查看:40
本文介绍了Spotify 的“播放器状态"在编辑器中可用,但在打包的应用程序中,它只获得“«constant ****kPSP»";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个测试代码:

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

在 AppleScript 编辑器中工作正常.但是,当我将脚本导出为应用程序时,我得到的只是:

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

为什么会这样?

推荐答案

似乎 Spotify 并没有将常量强制转换为字符串.由于编辑器不能像在 AppleScript 编辑器中运行脚本时那样从小程序强制它,因此返回四字母常量代码.由于您无法将玩家状态的值作为字符串进行测试,因此请尝试针对常量本身对其进行测试.

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

这篇关于Spotify 的“播放器状态"在编辑器中可用,但在打包的应用程序中,它只获得“«constant ****kPSP»";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆