Me gustaría mostrar con AppleScript un cuadro de diálogo que muestra mi título, artista y álbum actuales. Además, el icono del cuadro de diálogo debe ser la portada del álbum actual.
¿Es eso posible?
Me gustaría mostrar con AppleScript un cuadro de diálogo que muestra mi título, artista y álbum actuales. Además, el icono del cuadro de diálogo debe ser la portada del álbum actual.
¿Es eso posible?
Si lo es. Aquí es lo que se me ocurrió. Es tarde, así que es un poco difícil, me temo ...
Pashua.scpt
a la carpeta de aplicaciones EDIT : el código de la ilustración se tomó de esta respuesta .
#
# Start of code
#
global f, a
tell application "iTunes"
tell artwork 1 of current track
set d to raw data
if format is «class PNG » then
set x to "png"
else
set x to "jpg"
end if
end tell
set a to album of current track
end tell
set f to (((path to temporary items) as text) & "cover." & x)
set b to open for access file result with write permission
set eof b to 0
write d to b
close access b
-- Get the path to the folder containing this script
tell application "Finder"
set appPath to (path to applications folder)
#set thisFolder to (container of (path to me)) as string
set thisFolder to appPath as string
if "Pashua:Pashua.app:" exists then
-- Looks like the Pashua disk image is mounted. Run from there.
set customLocation to "Pashua:"
else
-- Search for Pashua in the standard locations
set customLocation to ""
end if
end tell
set customLocation to ""
log "customLocation: " & customLocation
log "f: " & f
try
set thePath to alias (thisFolder & "Pashua.scpt")
set pashuaBinding to load script thePath
tell pashuaBinding
-- Display the dialog
try
set pashuaLocation to getPashuaPath(customLocation)
set dialogConfiguration to my getDialogConfiguration(f)
set theResult to showDialog(dialogConfiguration, customLocation)
on error errorMessage
display alert "PashuaBinding: An error occurred" message errorMessage as warning
end try
end tell
on error errStr number errorNumber
display dialog errStr
end try
-- Returns the configuration string for an example dialog
on getDialogConfiguration(pashuaLocation)
if pashuaLocation is not "" then
set img to "img.type = image
img.x = 0
img.y = 50
img.maxwidth = 128
img.tooltip = Album Art
img.path = " & (POSIX path of pashuaLocation) & return
else
set img to ""
end if
return "
# Set window title
*.title = Currently playing...
# Introductory text
txt.type = text
txt.label = Track/Album Info
txt.default = Album: " & a & return & "
txt.height = 10
txt.width = 300
txt.x = 150
txt.y = 130
#txt.tooltip = This is an element of type “text”
db.type = defaultbutton
#db.tooltip = This is an element of type “defaultbutton” (which is automatically added to each window, if not included in the configuration)
" & img
end getDialogConfiguration
#
# END of CODE
#
Lea otras preguntas en las etiquetas itunes applescript script