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.
A:
I haven't done this myself but according to the documentation these are the steps (roughly):
- Create an
MPMediaQuery
to retrieve one or moreMPMediaItem
objects from the iPod library. - Ask those media items for their URL with
-[MPMediaItem valueForProperty: MPMediaItemPropertyAssetURL]
. - Create an
AVURLAsset
from the URL. - Create an instance of
AVAssetReader
for the asset. - Create one or more instances of
AVAssetReaderTrackOutput
(one for each track of the asset) and add them to the asset reader with-[AVAssetReader addOutput:]
. - Call
-[AVAssetReader startReading]
. - Call
-copyNextSampleBuffer
for each of yourAVAssetReaderTrackOutput
objects until you have read all the data.
See the documentation to all these classes for details.
Ole Begemann
2010-10-11 10:54:15