- Joined
- Aug 16, 2018
- Messages
- 1
- Reaction score
- 0
I've been trying to add a little variety (but not too much variety) to my morning music. Previously, I had been using Automator to play a single playlist every morning. But now I am trying to figure out an AppleScript that will chose a random playlist from a folder of playlist named "Morning" and play it in a random order. After some initial success, I've hit a roadblock. My main hurdle seems to be specifying that I want one of the playlists within the playlist folder.
My first working attempt was as follows:
This meets the basic criteria for what I wanted by working around the folder issue. For future use, I would prefer not to have to name the lists with numbers or modify the script if I add a new playlist.
To that end I tried:
This basically just selects the entire folder and plays a random track then shuffles through all the songs from all the folder... not what I was going for. I've tried a few other things but none seems to work.
Is there a way to have the script create a list of the playlists in the folder and then choose one of them at random?
I thought maybe I could use
but I get the error
My first working attempt was as follows:
Code:
on run
set playName to (random number from 1 to 5)
set morningPlaylist to playName as text
tell application "iTunes"
launch
stop
set todayPlay to user playlist morningPlaylist
set view of front window to todayPlay
set shuffle enabled to true
play todayPlay
end tell
end run
This meets the basic criteria for what I wanted by working around the folder issue. For future use, I would prefer not to have to name the lists with numbers or modify the script if I add a new playlist.
To that end I tried:
Code:
on run
set morningPlaylist to "Morning"
tell application "iTunes"
activate
set todayPlay to folder playlist morningPlaylist
play some track of todayPlay
set view of front window to todayPlay
set shuffle enabled to true
end tell
end run
This basically just selects the entire folder and plays a random track then shuffles through all the songs from all the folder... not what I was going for. I've tried a few other things but none seems to work.
Is there a way to have the script create a list of the playlists in the folder and then choose one of them at random?
I thought maybe I could use
Code:
play some playlist
if I try any variation of that. Apparently "some" and "playlist" aren't friends."error "iTunes got an error: Can’t make some data into the expected type." number -1700 to item"