1

Don't judge, my first code lol. How do I fix the stated issue and suggestions for improvement would be great. I just tried making something to pause music when I started a video and start playing again when I pause or close it.

set str to "🔊"
set playing to "playing"
set paused to "paused"
delay 1.1
tell application "iTunes"
    set playerstate to (get player state) as text
end tell
tell application "Google Chrome"
    get (count every tab of every window) as number
    set ntabs to result
end tell
repeat until (ntabs = 0)
    tell application "iTunes"
        set playerstate to (get player state) as text
    end tell
    if playerstate is playing then
        tell application "Google Chrome"
            if title of front window contains str then set noisy to true
            if not (title of front window contains str) then set noisy to false
        end tell
        if noisy = true then
            tell application "iTunes" to pause
            repeat until (noisy = false)
                tell application "Google Chrome"
                    if not (title of front window contains str) then set noisy to false
                end tell
            end repeat
            tell application "iTunes" to play
        end if
    end if
    tell application "Google Chrome"
        get (count every tab of every window) as number
        set ntabs to result
    end tell
end repeat
quit application "MusicPause"
  • Have you tried putting this in script debugger to see if it catches an error? – bmike Apr 6 at 18:47
  • In script debugger, the script stopped at the first "tell application "iTunes". i also added "on run" and "end run" before and after my script – Taylor Clark Apr 8 at 18:00

You must log in to answer this question.

Browse other questions tagged .