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:
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:
<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?
- App Sandbox: document-scoped bookmark not resolving; not returning any error
- swift + OS X sandboxing: treat 'NSVBOpenPanel' as a 'NSOpenPanel' :: because I need to get the sender in the delegate method
- Not receiving any UDP data on a socket when App Sandbox is on in Cocoa app
- iOS itunesconnect sandbox test account (Invalid Year)
- Trouble creating Security-Scoped Bookmark
- Sandbox entitlement to script iTunes via NSAppleScript
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.
- Swift : Extra Argument in call with scheduledTimerWithTimeInterval
- NSLocale currentLocale always returns “en_US” not user's current language
- didEnterRegion works in foreground but not background or other VCs
- What do I have to do to get Core Data to automatically migrate models?
- Blur effect using slider Is not working properly
- How are string constants in Objective-C stored/retrieved?
- iOS 8 enabled device not receiving PUSH notifications after code update
- Swift delegation – when to use weak pointer on delegate
- UIViewController viewDidLoad incorrect width/height
- AVAudioPlayer and performance issue in SpriteKit game
- Memory management and performSelectorInBackground:
- iPhone keyboard, Done button and resignFirstResponder
- Proximity sensor disable my screen
- Auto Layout Collection view according to various screen sizes
- Sending data from one ViewController to another.