Q: open Apple Music playlist AppleScript
Hi guys,
I'm using applescripts with my harmony hub remote to control some stuff in iTunes.
I have a 'launch iTunes' global service bound to a key command Ctrl Cmd S
tell application "iTunes"
activate
end tell
And a service within iTunes to start playing and shuffle an Apple Music playlist called the a-list electronic
use application "iTunes"
property playlistURL : "itmss://itunes.apple.com/gb/playlist/the-a-list-electronic/idpl.4705ab1ed97c4f 4bb54f48940faf5623"
property playlistName : "The A-List: Electronic"
tell application "iTunes" to stop
set shuffle enabled to true
set playlistToPlay to a reference to subscription playlist playlistName of source "iTunes Store"
open location playlistURL
set i to 0
repeat while i < 30
delay 1
try
tell playlistToPlay to if it exists then
play it
if player state is playing then return
end if
end try
set i to i + 1
end repeat
The problem is once I've launched iTunes the electronic playlist script does not work unless I hit launch iTunes again.
I have tried adding delays before the second script but nothing.
Is there any way to bring iTunes into focus before the second script runs so I don't need to run the first script again?
Running iTunes 12.4.2.4 on El Capitan Mac mini> mid 2010
Any help much appreciated. I am very much a novice with AppleScript.
a
a
Posted on Aug 2, 2016 6:55 AM