0

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?

Alex
  • 5,009
  • 3
  • 39
  • 73
  • Are u sure your app will submitted by Apple? – Nikolai Nagornyi May 08 '13 at 17:27
  • @NikolaiNagorny what do you mean? I'm the one submitting my app to the MAS – Alex May 08 '13 at 17:50
  • i want to use Scripting Bridge but i uncertain that Apple submit my app with this technology... – Nikolai Nagornyi May 08 '13 at 18:30
  • 1
    @NikolaiNagorny I haven't found one source that states that Apple will not accepted an app which uses Scripting Bridge (including the [Mac App Store Review Guidelines](https://developer.apple.com/appstore/mac/resources/approval/guidelines.html)) – Alex May 08 '13 at 18:52
  • @Alex Do you know what needs to be added to the entitlements file to be able to add a playlists, and then tracks to that playlist? I've tried com.apple.iTunes.library.write, but it does not seem to work. – abroekhof Jun 01 '13 at 17:07
  • @Alex I put a question here if you want to get some points for answering! http://stackoverflow.com/questions/16875345/creating-playlists-in-itunes-using-scripting-bridge-in-a-sandboxed-app – abroekhof Jun 01 '13 at 17:35
  • @Alex Just to get an update, was your app accepted by apple appstore ? I am doing something similar – Ahmed Jul 25 '14 at 03:27
  • @Alex Are you able to access iTunesTrack location path ? not working for me on 10.8 with entitlement of accessing music read any ideas ? – Ahmed Jul 25 '14 at 06:03
  • @Ahmed Yes, my app had no problem in getting accepted by Apple. Regarding iTunesTrack location, I'm afraid I can't help you there since I never tried accessing that. – Alex Jul 25 '14 at 07:10

1 Answers1

0

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.

Alex
  • 5,009
  • 3
  • 39
  • 73