1

Does anyone know how to play a selected .m4a file from the iPhone's iPod music library using a AVAudioPlayer? Is it possible to either export or copy the file to local Documents directory of the iPhone? Can anyone share any sample code to successfully handle this?

Thanks

Bryan C
  • 1,594
  • 4
  • 16
  • 30

1 Answers1

1

Using the avaudioplayer to play music from your music library is not possible. Nor is there a way to copy files from the music library to the local path of your app. If you use the avplayer you can access the music library.

mightym
  • 191
  • 2
  • 14
  • 1
    Actually, this is not correct. I have been able to play mp3 files from my music library without any problem. However I get an error "The operation couldn't be completed (OSStatus error -43.)" when I attempt to play an m4a file. To get it to work with mp3 files, I used the MPMediaPickerController to select a file from my music library. In the didPickMediaItems callback method, you can get the song URL from the MPMediaItem(s) and use this URL in AVAudioPlayer initWithContentsOfURL. – Teevus Nov 05 '12 at 06:49