Spotify的"球员的状态和QUOT;在编辑器中可用,但在打包应用程序,它就会只"«不断**** kPSP»" [英] Spotify's "player state" is available in the editor, but in a packaged app, it gets only "«constant ****kPSP»"

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

问题描述

下面是一个测试code:

Here's a testing code:

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:

为什么会出现这种情况?

Why is this happening?

推荐答案

看来,Spotify的是不是强迫恒成一个字符串。因为它,当你正在运行的AppleScript在编辑器中的脚本执行编辑器不能从applet强制它,返回四个字母常数code。既然你不能测试选手状态的值作为一个字符串,尝试测试其对常量自己。

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的"球员的状态和QUOT;在编辑器中可用,但在打包应用程序,它就会只"«不断**** kPSP»"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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