I would absolutely love the ability to display the Album Art from iTunes on my control pages. HAS ANYONE done this yet. Here is my example:
Skiddy wrote:Yes.... and No.
I wrote an applescript to do this using variables and image files but there's an issue with Indigo in that when you display a variable as an image (the album art) it does not change/update the image file automatically when the variable itself changes like it does with text values. You have to do a manual refresh of the browser window. What I have is close but not close enough unfortunately.
property outputFolder : "Library:Application Support:Perceptive Automation:"
property filename : "AlbumArt.png"
property maxImageDataSize : 340000 -- the maximum size of the outputted image data in bytes.
property scaleGranularity : 0.05 -- increase this for faster, but less accurate downscaling.
on run
set outputPath to outputFolder & filename
if isApplicationRunning("com.apple.iTunes") then
tell application id "com.apple.iTunes"
if (player state is playing) then
my writeITunesArtworkToFile(outputPath)
return
end if
end tell
end if
if isApplicationRunning("com.ilabs.PandorasBox") then
tell application id "com.ilabs.PandorasBox"
if (player state is playing) then
my writePandorasBoxArtworkToFile(outputPath)
return
end if
end tell
end if
display dialog "No active players." buttons {"OK"} default button 1
end run
-- is an application running?
on isApplicationRunning(bundleID)
tell application "System Events" to return (exists (some process whose bundle identifier is bundleID))
end isApplicationRunning
-- write Pandoras Box current song artwork to path
on writePandorasBoxArtworkToFile(filename)
try
tell application id "com.ilabs.PandorasBox" to set the_data to (get artwork of current song)
exportRawDataToPath(the_data, filename)
end try
end writePandorasBoxArtworkToFile
-- write iTunes current track artwork to path
on writeITunesArtworkToFile(filename)
try
tell application id "com.apple.iTunes" to set the_data to (get raw data of artwork 1 of current track)
exportRawDataToPath(the_data, filename)
end try
end writeITunesArtworkToFile
-- write artwork data to path.
on exportRawDataToPath(theData, outputPath)
try
-- write temporary TIFF data.
set tempPath to GetEnclosingFolder(outputPath) & "temp.tiff"
set fileReference to (open for access tempPath with write permission)
tell application "System Events"
write theData to fileReference starting at 0
set file type of (tempPath as alias) to ".tiff"
end tell
close access fileReference
set scaleFactor to 1.0
tell application "Image Events"
launch
repeat
set tempImage to open tempPath
scale tempImage by factor scaleFactor
set outputImageFile to save tempImage in outputPath as PNG
if (size of outputImageFile > maxImageDataSize and scaleFactor > 0) then
set scaleFactor to scaleFactor - scaleGranularity
else
exit repeat
end if
end repeat
close
end tell
-- delete temporary files.
do shell script ("rm -f " & quoted form of POSIX path of (tempPath as alias))
if (scaleFactor ≤ 0.01) then ¬
do shell script ("rm -f " & quoted form of POSIX path of (outputPath as alias))
end try
end exportRawDataToPath
on GetEnclosingFolder(myPath)
set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
set AppleScript's text item delimiters to {":"}
set pathItems to text items of (myPath as text)
if last item of pathItems is "" then set pathItems to items 1 thru -2 of pathItems -- its a folder
set parentPath to ((reverse of the rest of reverse of pathItems) as string) & ":"
set AppleScript's text item delimiters to oldDelimiters -- always restore original delimiters
return parentPath
end GetEnclosingFolder
on GetLastPathComponent(myPath)
set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
set AppleScript's text item delimiters to {":"}
set pathItems to text items of (myPath as text)
if last item of pathItems is "" then set pathItems to items 1 thru -2 of pathItems -- its a folder
set parentPath to last item of pathItems
set AppleScript's text item delimiters to oldDelimiters -- always restore original delimiters
return parentPath
end GetLastPathComponent
Users browsing this forum: No registered users and 0 guests