iTunes脚本编写与脚本桥&沙盒 [英] iTunes scripting with Scripting Bridge & Sandboxing

查看:169
本文介绍了iTunes脚本编写与脚本桥&沙盒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它告诉iTunes使用ScriptingBridge框架播放音乐。该应用程序或者告诉iTunes播放播放列表或者某个曲目。

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>

我已经测试没有应用程序沙箱和代码工作完美。尽管播放列表代码工作正常,但是播放曲目不会工作。我检查了控制台应用程序,似乎没有记录,涉及sandboxd和我的应用程序。

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.

一开始我想我可能会缺少一些 access-group 在我的权限文件,但是我认为这将没有意义,因为我已经有播放一个。我没有找到任何列表的访问组在iTunes上的网络(我甚至试图使用sdef从iTunes获取属性列表,搜索'access-group',但没有发现 - 它不存在),所以我不能

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?

推荐答案

没关系。原来,我在 SBElementArray 上调用 filteredArrayUsingPredicate:找出我想播放的曲目, >不知何故正在搞乱。现在我使用方法 objectWithName:,它工作。

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.

这篇关于iTunes脚本编写与脚本桥&amp;沙盒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆