Yup.
Looks like everything except playlist is reporting correctly.
marketability wrote:incidentally - how are you viewing the custom states in the GUI?
-- configuration properties to set specific to your
-- own setup
property outputTempFN : "Library:Application Support:Perceptive Automation:Indigo 6:IndigoWebServer:images:iTunesCurrentAlbum.tiff"
property outputPNGFN : "Library:Application Support:Perceptive Automation:Indigo 6:IndigoWebServer:images:iTunesCurrentAlbum.png"
property noArtworkFN : "Library:Application Support:Perceptive Automation:Indigo 6:IndigoWebServer:images:iTunesNoArtworkAvailable.png"
property notPlayingFN : "Library:Application Support:Perceptive Automation:Indigo 6:IndigoWebServer:images:iTunesNotPlaying.png"
property targetSize : 256
-- main run routine
on run
-- checks to ensure that itunes is running and available
if my checkItunesIsActive() is false then
-- uncomment below to show an error or add your own logging
-- set opt to (display dialog "iTunes is not running." buttons {"OK"} default button 1 with title "Cannot proceed..." with icon 0 giving up after 30)
my outputPlaceholderImage(notPlayingFN)
return false
end if
-- ensure that itunes will respond, apparently some version will not if a modal dialog
-- window is showing
if my itunesIsNotAccesible() is true then
-- uncomment below to show an error or add your own logging
-- set opt to (display dialog "Close any utility windows that may be open in iTunes." buttons {"OK"} default button 1 with title "Cannot proceed..." with icon 0 giving up after 30)
my outputPlaceholderImage(notPlayingFN)
return false
end if
-- itunes should be available… attempt to process now
tell application id "com.apple.iTunes"
if (player state is playing) or (player state is paused) then
copy (get rating of current track) to trackRating
if (artworks of current track exists) then
-- the current track has artwork available, attempt to output
-- that to a PNG now
set artwork_data to (get raw data of first artwork of current track)
my outputAlbumArtwork(artwork_data)
-- THIS IS MIKE'S EDIT FOR TRACK RATING <===============================
--Original locations copy (get rating of current track) to trackRating
-- tell application "IndigoServer"
-- set value of variable "iTunesStars" to trackRating
-- end tell
-- THIS IS MIKE'S EDIT FOR TRACK RATING <===============================
else
-- export the "no artwork available" file to the output
my outputPlaceholderImage(noArtworkFN)
end if
else
-- export the "not playing" artwork file to the output
my outputPlaceholderImage(notPlayingFN)
end if
-- -----------this is Mike's edit for telling Indigo <==================================
tell application "IndigoServer"
set value of variable "iTunesStars" to trackRating / 20
end tell
end tell
end run
-- this routine checks to see if iTunes is running
to checkItunesIsActive()
tell application "System Events" to return (exists (some process whose name is "iTunes"))
end checkItunesIsActive
-- this routine ensures that itunes is responding to applescript commands
to itunesIsNotAccesible()
try
with timeout of 1 second
tell application id "com.apple.iTunes" to get name of library playlist 1
end timeout
on error
return true
end try
return false
end itunesIsNotAccesible
-- this routine will output the artwork data provided to the artwork
-- file specified in the properties at top
to outputAlbumArtwork(artwork_data)
set tempFileHandle to (open for access outputTempFN with write permission)
try
tell application "System Events"
write artwork_data to tempFileHandle starting at 0
set file type of (outputTempFN as alias) to ".tiff"
end tell
close access tempFileHandle
tell application "Image Events"
launch
set tempImageRef to open outputTempFN
scale tempImageRef to size targetSize
save tempImageRef as PNG in outputPNGFN with icon
close tempImageRef
end tell
on error err_msg
close access tempFileHandle
-- log error message if desired
-- set opt to (display dialog "Error: " & err_msg buttons {"OK"} default button 1 with title "Cannot proceed..." with icon 0 giving up after 30)
end try
end outputAlbumArtwork
-- this rouitne will output the given filename, assumed to already be a PNG,
-- to the output filename defined in the properties up top
to outputPlaceholderImage(filename)
set outputFileHandle to (open for access (outputPNGFN as alias) with write permission)
try
write (read (filename as alias)) to outputFileHandle starting at 0
close access outputFileHandle
on error err_msg
close access outputFileHandle
-- log error message if desired
-- set opt to (display dialog "Error: " & err_msg buttons {"OK"} default button 1 with title "Cannot proceed..." with icon 0 giving up after 30)
end try
end outputPlaceholderImage
marketability wrote:incidentally - how are you viewing the custom states in the GUI?
Do you mean in the Mac Client UI? Just select the device from the device list and use the split view handle (just below the list) to expand the detail section below the list to show the custom states tile.
If you're talking about viewing them on a custom control page, then just use the standard device state control page element and select the state.
Users browsing this forum: No registered users and 1 guest