9

How can I get the content (raw/sample data) of an iPod-track? I've seen apps like "Ringtone Designer" and iMovie which can do it, but I have no idea which api they use or what they do. I could imagine that iMovie uses private apis, but "Ringtone Designer" is a third-party app, so it must be possible with the public api-functions.

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
Dominik Seibold
  • 2,439
  • 1
  • 23
  • 29

1 Answers1

14

I haven't done this myself but according to the documentation these are the steps (roughly):

  1. Create an MPMediaQuery to retrieve one or more MPMediaItem objects from the iPod library.
  2. Ask those media items for their URL with -[MPMediaItem valueForProperty: MPMediaItemPropertyAssetURL].
  3. Create an AVURLAsset from the URL.
  4. Create an instance of AVAssetReader for the asset.
  5. Create one or more instances of AVAssetReaderTrackOutput (one for each track of the asset) and add them to the asset reader with -[AVAssetReader addOutput:].
  6. Call -[AVAssetReader startReading].
  7. Call -copyNextSampleBuffer for each of your AVAssetReaderTrackOutput objects until you have read all the data.

See the documentation to all these classes for details.

Ole Begemann
  • 135,006
  • 31
  • 278
  • 256
  • Would you provide sample code? please, or reference – Arpit B Parekh Dec 07 '17 at 14:14
  • Exists some sample code with a full processes of library music playback? Listing all artists, select one, list of all albums, select one or select all songs and finally all songs? Exactly the same as old iPod classics? – Markus Nov 13 '18 at 09:57