Applescript update iTunes stream title without obstructing rest of script -
i using code below current itunes stream title. works great. need be, script updates every time when itunes stream title changes, variable title updates well.
repeat tell application "itunes" set title current stream title end tell delay 2 end repeat
however, because of ongoing "repeat" function, rest of script not execute. know of way still variable title updated when itunes changes title, not obstruct rest of script? if sort of runs in background? thank you!
a solution, use handler (handlers known functions, subroutines, or methods). put rest of script in handler, call handler loop.
like :
set oldtitle "" repeat set t "" try tell application "itunes" set t current stream title end try if t not "" , t not oldtitle -- title changed set oldtitle t dosomething(t) -- call handler end if delay 3 end repeat on dosomething(title) -- put rest of script here end dosomething
Comments
Post a Comment