iTunes scripting with Scripting Bridge & Sandboxing

我与影子孤独终老i 提交于 2019-11-30 21:04:34

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/16420120/itunes-scripting-with-scripting-bridge-sandboxing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!