2

How can I write an audio file picked from mediaPicker into my app's Documents Folder?

Basically I am selecting a audio file from iPod Library.

I want that this selected file be copied into my app's Documents folder.

So that I can reference it from my app's Documents folder.

What can be done?

Thanks.

Meghan
  • 1,004
  • 1
  • 15
  • 34

3 Answers3

3

I recommend TSLibraryImport in iOS4+

http://code.google.com/p/tslibraryimport/

https://bitbucket.org/artgillespie/tslibraryimport

Ilias Karim
  • 4,798
  • 3
  • 38
  • 60
1

I found a way to convert iPod libray song and write it to documents directory, using

From iPod Library to PCM Samples in Far Fewer Steps Than Were Previously Necessary

Thanks Mats Stijlaart for your help. But I got the solution for this.

Hope this helps everyone.

Meghan
  • 1,004
  • 1
  • 15
  • 34
0

I do not think this is allowed. This will make it more easy to copy file bought in iTunes, so i do not think apple will allow that.

When you pick music from your music library, you will have to use a MPMediaPickerController with the following delegate method:

- (void) mediaPicker: (MPMediaPickerController *) mediaPicker didPickMediaItems: (MPMediaItemCollection *) mediaItemCollection

MPMediaItemCollection is some kind of list. It's items are instances of the MPConcreteMediaItem class. The MPMusicPlayerController can play a MPMediaItemCollection, but with MPConcreteMediaItems but you can not do anything.

Mats Stijlaart
  • 5,058
  • 7
  • 42
  • 58
  • Thanks for input, Can I store references of MPMediaItemCollection somewhere? I mean path of that file, to use that file next time I open my app? – Meghan Mar 03 '11 at 04:57
  • MPMediaItemCollection inherits from MPMediaEntity which inherits from NSObject. MPMediaEntity is conform to the NSCoding protocol, so it means it is serializable and you can put the data in a file.
    This means you can also serialize a MPMediaItemCollection. I do not know if it will work, but i'm almost certain apple did implement it (probably the way Apple stores playlists).
    – Mats Stijlaart Mar 03 '11 at 12:26