通过ScriptingBridge在iTunes中获取特定曲目 [英] get a specific track in itunes via ScriptingBridge

查看:140
本文介绍了通过ScriptingBridge在iTunes中获取特定曲目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在更新OS X程序以接受iTunes放置,修改文件中的元数据,然后刷新(获取信息)放置的文件,以便iTunes可以更新其元数据库.

I'm updating my OS X program to accept iTunes drops, modify the metadata in the file, then refresh (Get Info) the dropped file(s) so iTunes can update its' metadata library.

我已经使drops工作了,它们提供了有关该文件的一些其他信息的字典,包括轨道ID,永久ID和位置.现在,我需要通过文件位置或放置信息提供的持久性ID来获取特定的曲目,因此我可以调用其上的refresh方法来强制iTunes重新检查文件并更新更改到元数据.

I've got the drops working, which provide a dictionary of some misc info about the file including track ID, persistent ID, and Location. I'm at the point now where I need to get a specific track, either by file location or the persistant ID provided by the drop info, so I can call the refresh method on it to force iTunes to reexamine the file and update the changes to the metadata.

我已经导入了iTunes头文件并创建了SBApplication对象,在这一点上,我非常想办法找到一种有效的方法来获得正确的音轨.

I've got the iTunes header file imported and the SBApplication object created, I'm pretty stuck at this point on an efficient way to get the proper track.

推荐答案

如上所述,我已经可以访问有关iTunes drop提供的文件的某些信息.我需要根据iTunes库中文件拖放所提供的文件名或persistentID来匹配有关该文件的信息,我的解决方案是针对iTunes脚本桥返回的库集合对iTunes库使用谓词过滤器

As stated, I already had access to some info about a file provided by an iTunes drop. I needed to match up info about that file based on either the file name or persistentID provided by the drop to the file in the iTunes library my solution was to use a predicate filter on the iTunes library against the library collection returned by the iTunes scripting bridge.

    iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"];

    SBElementArray *sources = [iTunes sources];

    SBElementArray *entireLibrary = [[[[sources objectAtIndex:0] libraryPlaylists] objectAtIndex:0] fileTracks];

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"persistentID == %@", persistentID];

    [entireLibrary filterUsingPredicate:predicate];

这篇关于通过ScriptingBridge在iTunes中获取特定曲目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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