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.
我有一个应用程序告诉iTunes使用ScriptingBridge框架播放音乐。这个应用程序要么告诉iTunes播放一个播放列表,要么播放某个曲目。这款应用也是沙箱设计。
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.
我已经测试了没有应用沙箱和代码完美地工作。通过沙盒播放列表代码可以很好地工作,但是播放轨迹就不行。我用控制台应用程序进行了检查,似乎没有记录任何与sandboxd和我的应用有关的内容。
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.
一开始我认为我可能在我的权限文件中丢失了一些访问组,但是后来我认为这没有意义,因为我已经有了回放。我在网上找不到任何iTunes的访问组列表(我甚至尝试使用sdef从iTunes获取属性列表并搜索“访问组”,但什么也没找到——它不在那里),所以我无法确认是否还需要什么。
To sum up, why is sandbox preventing this from working?
综上所述,为什么沙箱阻止了这个工作?
1 个解决方案
#1
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.
不要紧。原来我是在调用filteredArrayUsingPredicate:在SBElementArray上查找我想播放的曲目,结果搞砸了。现在我使用方法objectWithName:,它可以工作。
#1
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.
不要紧。原来我是在调用filteredArrayUsingPredicate:在SBElementArray上查找我想播放的曲目,结果搞砸了。现在我使用方法objectWithName:,它可以工作。