iTunes scripting with Scripting Bridge & Sandboxing

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:

  • Why are subviews of an NSView not sent a release message when a Cocoa application terminates?
  • Why is NSOpenPanel/NSSavePanel showing memory leak?
  • Launching phone/email/map links in WKWebView
  • resetCursorRects not working (new cursor only flashes as mouse enters)
  • What is the simplest implementation of Markdown for a Cocoa application?
  • Best way to use XML-RPC in Cocoa application?
  • iTunesPlaylist* playlist = ...

    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:

            <string></string> // I also have this to read the playlists/tracks the user has on his library

    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?

    Solutions Collect From Internet About “iTunes scripting with Scripting Bridge & Sandboxing”

    Never mind. It turns out I was calling filteredArrayUsingPredicate: on an SBElementArray to find out the track I wanted to play and that somehow was messing things up. Now I use the method objectWithName: and it works.