我正在尝试返回我的计算机上正在播放的当前 iTunes 曲目的信息。
我可以获得这样的单一信息:
tell application "iTunes"
get name of current track
end tell
例如,这会返回
Thunderstruck
。
但是我是否可以获取当前曲目的更多信息,以便它返回如下内容:
"AC/DC, Thunderstruck, Iron Man 2"
这可能吗?或者我必须创建多个脚本吗?
谢谢
要获得
name
、artist
和 album
tell application "iTunes"
get {name, artist, album} of current track
end tell
结果是一个列表
得到一切
tell application "iTunes"
get properties of current track
end tell
结果创纪录
如果您使用 JXA,则:
// File: GetTrackInfo.jxa
const appMusic = Application("com.apple.Music");
const currentTrack = appMusic.currentTrack();
const properties = currentTrack.properties()
// Get track info as a JSON
console.log(JSON.stringify(properties, null, 2))
// Get certain track info property.
console.log(properties.name)
// File: GetTrackInfoAndCopyToClipboard.jxa
const currentApp = Application.currentApplication();
currentApp.includeStandardAdditions = true;
const appMusic = Application("com.apple.Music");
const currentTrack = appMusic.currentTrack();
const result = `${currentTrack.artist()} - ${currentTrack.name()} @ ${currentTrack.album()}`;
console.log(`Result: ${result}`);
// Bonus, copying track into into Clipboard and sending notification.
currentApp.setTheClipboardTo(result);
currentApp.displayNotification(result);