I've written this code in Script Editor. The program loops once or twice but stops soon after. The purpose of the code is to infinitely play "My heart will go on" on the victim's Mac computer. Instead, it only loops twice and can break quite easily. How can I make this foolproof?
repeat
set volume 10
try
using terms from application "Spotify"
if player state of application "Spotify" is paused then
tell application "Spotify" to play
return "unpaused"
end if
end using terms from
tell application "System Events" to (name of processes) contains "Spotify"
if true then
tell application "Spotify"
play track "spotify:track:33LC84JgLvK2KuW43MfaNq" in context "spotify:playlist:2CLbqnKJirVefl8xdtMvEN"
end tell
else
open application "Spotify"
end if
end try
end repeat