मैं ट्रैक परिवर्तन का पता लगाने के लिए स्पॉटिफी की एप्पलस्क्रिप्ट लाइब्रेरी के माध्यम से सबसे अच्छा तरीका जानने की कोशिश कर रहा हूं। अब तक, मैंने प्लेयर की स्थिति की जांच करने का प्रयास किया है - यदि यह 0 के बराबर है तो यह एक नया ट्रैक है और ग्रॉल अधिसूचना फिर से दिखाई देती है। (अगर कोई गाना शुरू कर देता है, तो यह अधिक काम नहीं करता है)एप्पलस्क्रिप्ट में निगरानी स्पॉटिफा ट्रैक परिवर्तन की निगरानी?
मुझे आश्चर्य है कि क्या अधिक व्यावहारिक विधि में एक निष्क्रिय आईट्यून्स स्क्रिप्ट चल रही है और प्रत्येक दो सेकंड में बदलने के लिए वर्तमान ट्रैक नाम की जांच कर रहा है। मुझे चिंता है कि यह एक हॉग स्मृति-वार का थोड़ा सा हो सकता है। मैं इस कोड को या तो काम नहीं कर सकता।
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