2014-01-27 33 views
1

我已经写在VBA改变在iTunes的评论下面的代码跟踪在Windows环境中:更改iTunes曲目评论

Dim iTunes As New iTunesApp 
Dim library As IITLibraryPlaylist 
Dim tracksByArtist As IITTrackCollection 
Dim xSearch As String, xComment As String 
Dim track As IITFileOrCDTrack 
Dim i As Long, j As Integer 

Set library = iTunes.LibraryPlaylist 
xComment = "myComment" 

For i = 1 To NumberOfSongInItunes 'Number of songs in library 
     If xArray(9, i) = "Target" Then 'xArray holds information that i've previously read from the library or xml file 
      xSearch = "Artist Name " & "Album " & "Track Name" 
      Set tracksByArtist = library.Search(xSearch, 0) 

      For Each track In tracksByArtist 
       track.Comment = xComment 
      Next 
    End If 
Next 

Set iTunes = Nothing 

我一直在玩弄在Xcode与ITLibrary,ITLibAlbum,ITLibArtist等,但没有成功。有任何想法吗?最好不要使用苹果,因为它会很慢。

回答

0

我不确定它适合您的需求,但Scripting Bridge框架始终是可选的。下面的例子只是改变了当前正在播放哪条曲目的评论,但您可以使用iTunes.h和Scripting Bridge基本上完成您想要的iTunes及其曲目。

#import <ScriptingBridge/ScriptingBridge.h> 
#import "iTunes.h" 


iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; 
[[iTunes currentTrack] setComment:@"I just added this cool comment to the current track!"]; 

有最近发生的一些脚本桥接头on github的副本,但我建议你自己编译,以确保一切是最新的。说明可以在这里找到https://developer.apple.com/library/mac/DOCUMENTATION/Cocoa/Conceptual/ScriptingBridgeConcepts/Introduction/Introduction.html

基本上,要生成iTunes.h您需要运行以下命令。

sdef /Applications/iTunes.app | sdp -fh --basename iTunes 
+0

谢谢,Scripting Bridge框架适用于我。所以我假设一般框架是使用iTunes Library Framework Reference来推断数据库,然后使用Scripting Bridge来实现? – alex

+0

@alex我相信如此。就像FYI一样,这可以用于安装在OS X上的许多应用程序,而不仅仅是iTunes。 –

0

没有公开的API。你将不得不打开XML文件并编辑它。它很容易突破

+0

因此,苹果已经发布了一个API的窗口,但不是本地平台?? – alex

+0

是的,这基本上它亚历 –

+0

谢谢,编辑XML不会工作我不认为这些更改将不会反映在iTunes中。我真的不明白苹果是如何为Mac发布api的,它没有任何意义,除非我错过了一些东西。 。? – alex