【问题标题】:Is it possible to modify iTunes tracks using Objective-C?是否可以使用 Objective-C 修改 iTunes 曲目?
【发布时间】:2012-05-04 14:03:15
【问题描述】:

问题就在标题中 :) 我正在使用 Objective-C 和 Scripting Bridge。我知道可以从 iTunes 获取信息(只读),但我看不到任何修改曲目的方法,例如更改其名称。用这种或另一种技术有可能吗?

非常感谢:)

【问题讨论】:

    标签: objective-c itunes scripting-bridge


    【解决方案1】:

    嗯,从 AppleScript 编辑器的脚本库中,我可以看到 file_track 继承自 item 并且 item 具有读写属性 name。因此,您应该能够像阅读它一样轻松地设置它。

    编辑:实际上,几乎每条元数据都是track 的一部分(其中file_track 也继承了),并且大多数都是读写属性...

    Doug Adams 有一个such script 可以更改iTunes 中歌曲的标题。可以看看吗?

    至于通过Objective-C设置,或许this documention可以帮到你。

    摘自网站:

    清单 2-3 设置 Finder 项的锁定属性

    int main (int argc, const char * argv[]) { 
       NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 
       FinderApplication *theFinder = [SBApplication applicationWithBundleIdentifier: @"com.apple.finder"]; 
       SBElementArray *trashItems = [[theFinder trash] items]; 
       if ([trashItems count] > 0) { 
           for (FinderItem *item in trashItems) { 
               if ([item locked]==YES) 
                   [item setLocked:NO];          // <<<-- Setting the property
           } 
       } 
       [pool drain]; 
       return 0; 
    } 
    

    你试过了吗:

    iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; 
    [[iTunes currentTrack] setName:@"The New Song Title"]); 
    

    【讨论】:

    • 好的,谢谢,我去看看。由于 iTunes.h 文件中带有属性声明的关键字复制,我感到困惑。事实上它会起作用,希望如此!
    • 如果它解决了您的问题,请不要忘记接受答案。 :)
    • 哇,这太棒了:) 不过我真的真的很陌生
    • 注意:由于 currentTrack 和 name 是属性,您可以使用属性语法:iTunes.currentTrack.name = @"The New Song Title";
    猜你喜欢
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多