I have an app which tells iTunes to play music using the ScriptingBridge framework. The app either tells iTunes to play a playlist or a certain track. The app is also sandboxed.
To play a playlist, here's what I have:
iTunesPlaylist* playlist = ...
[playlist playOnce: YES];
To play a track, it's pretty straightforward as well:
iTunesTrack* track = ...
[track playOnce: YES];
Since my app is sandboxed, I have the following lines in my entitlements file:
<key>com.apple.security.scripting-targets</key>
<dict>
<key>com.apple.iTunes</key>
<array>
<string>com.apple.iTunes.library.read</string> // I also have this to read the playlists/tracks the user has on his library
<string>com.apple.iTunes.playback</string>
</array>
</dict>
I have tested without app sandboxing and the code works perfectly. With sandboxing though the playlist code works fine, but playing a track does not work. I checked with the Console app and nothing seems to be logged that concerns sandboxd and my app.
At first I thought that I might be missing some access-group
in my entitlements file, but then I thought that wouldn't make sense because I already have the playback
one. And I couldn't find any list of access groups for iTunes on the net (I even tried using sdef to get a property list from iTunes and search for 'access-group' but found nothing - it's not there) so I couldn't confirm if I needed any more.
To sum up, why is sandbox preventing this from working?
Never mind. It turns out I was calling
filteredArrayUsingPredicate:
on anSBElementArray
to find out the track I wanted to play and that somehow was messing things up. Now I use the methodobjectWithName:
and it works.