我試圖找出通過Spotify的Applescript庫來檢測跟蹤更改的最佳方式。到目前爲止,我已經嘗試過檢查玩家的位置 - 如果它等於0,這是一個新的軌道,並再次出現低吼通知。 (如果有人開始播放歌曲等,這種方式並不適用)在Applescript中監控Spotify曲目變化?
我想知道更合理的方法是讓空閒的iTunes腳本運行並檢查當前曲目名稱以便每隔幾秒鐘更改一次。我擔心這可能是一種記憶式的記憶方式。我無法讓這個代碼運行。
tell application "System Events"
-- checks for instance of Growl and Spotify, does not run if both programs are not active
set isRunning to ¬
(count of (every process whose name is "Growl")) > 0
(count of (every process whose name is "Spotify")) > 0
end tell
--establish empty variable to be filled by song title later
global latest_song
set latest_song to ""
on idle
tell application "Spotify"
if player state is playing then
copy name of current track to current_tracks_name
-- runs match between last and current song titles
if current_tracks_name is not latest_song then
copy current_tracks_name to latest_song
set who to artist of current track
set onwhat to album of current track
tell application "Growl"
-- Make a list of all the notification types
-- that this script will ever send:
set the allNotificationsList to ¬
{"SpotifyNewTrack"}
-- Make a list of the notifications
-- that will be enabled by default.
-- Those not enabled by default can be enabled later
-- in the 'Applications' tab of the growl prefpane.
set the enabledNotificationsList to ¬
{"SpotifyNewTrack"}
-- Register our script with growl.
-- You can optionally (as here) set a default icon
-- for this script's notifications.
register as application ¬
"Spotify" all notifications allNotificationsList ¬
default notifications enabledNotificationsList ¬
icon of application "Spotify"
-- Send a Notification...
notify with name ¬
"SpotifyNewTrack" title ¬
current_tracks_name description ¬
who application name "Spotify"
end tell
end if
return 5
end if
end tell
end idle
這可能有點複雜,但任何幫助表示讚賞。
做什麼版本的低吼Spotify的支持: 此代碼是對發現的? – ryryan