How to import an mp3 song into iTunes using Objective-C?

给你一囗甜甜゛ 提交于 2019-12-04 14:38:39

Ok, so after some research on Scripting Bridge, just like Andrew Madsen suggested. Here is the answer to my own question.

This has been implemented and tested...

  1. Add the ScriptingBridge Framework to your Mac OS Project.
  2. Generate the iTunes.h file by writing the following in the terminal.

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

  3. Import the newly created iTunes.h file into your Mac OS Project and do an #import "iTunes.h" in the class you would like to use the Scripting Bridge in.

  4. Use this code to add a song to iTunes:

    iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; iTunesTrack * track = [iTunes add:[NSArray arrayWithObject:[NSURL fileURLWithPath:filePath]] to:playlist];

  5. That is all to it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!