Given a name of an album or artist I would like to tell iTunes to play all songs by that artist or on that album. How can I do this? I know how to get all the songs to play by filtering an array with all the tracks, but how do I tell iTunes to play only those I want?
I know I can use this code to get all the tracks I want to play, but I have no idea how to tell iTunes to play them in sucession. Any ideas?
// Get the app
iTunesApplication* iTunes = [SBApplication applicationWithBundleIdentifier: @"com.apple.iTunes"];
// Get the library
iTunesSource* library;
for (iTunesSource* thisSource in [iTunes sources]) {
if ([thisSource kind] == iTunesESrcLibrary) {
library = thisSource;
break;
}
}
SBElementArray* tracks;
for (iTunesPlaylist* playlist in [library playlists]) {
if ([playlist specialKind] == iTunesESpKMusic) {
tracks = [playlist searchFor: name only: type == 0 ? iTunesESrAAlbums : iTunesESrAArtists];
}
}
// There. Now what? how do I play all the tracks in 'tracks'?
So it seems iTunes does not have an AppleScript/Scripting Bridge command to play songs by a certain artist/on a certain album. And according to this question, it's not possible to tell iTunes to play a custom list of tracks without creating a new playlist (which I don't want to do). In short, there's really no way to solve this problem...