如何使用Objective-C将mp3歌曲导入iTunes? [英] How to import an mp3 song into iTunes using Objective-C?

查看:148
本文介绍了如何使用Objective-C将mp3歌曲导入iTunes?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建需要将mp3文件导入iTunes的Mac OS应用程序...

I am building a Mac OS Application which needs to import an mp3 file into iTunes...

似乎找不到任何可以帮助我实现这一目标的框架.我想到的唯一方法是修改"iTunes Music Library.xml".

Can't seem to find any framework that would help me achieve this. The only way I can think of doing this is modifying the "iTunes Music Library.xml".

我希望你们中的一个能为我提供更好,更清洁的解决方案.

I'm hoping one of you can point me to a better and cleaner solution.

先谢谢您.

推荐答案

好,所以在对脚本桥进行了一些研究之后,就像安德鲁·麦德森(Andrew Madsen)所建议的那样.这是我自己的问题的答案.

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. ScriptingBridge框架添加到您的Mac OS项目中.
  2. 通过在终端中编写以下内容,
  3. 生成 iTunes.h 文件.

  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

将新创建的 iTunes.h 文件导入您的Mac OS Project,并在您想要的类中执行 #import"iTunes.h" 在其中使用脚本桥.

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.

使用以下代码将歌曲添加到iTunes:

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];

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

仅此而已.

这篇关于如何使用Objective-C将mp3歌曲导入iTunes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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