iPhone Media Player Framework accessing raw file
I'm interested in using the Media Player framework on iPhone to access audio in the user's library. I want to be able to load a given audio file and then perform some specialised filtering on it.
Ideally I want to be able to directly load the audio file (or portion thereof for streaming) then use the audio converter services to perform decompression. Once I have the linear PCM data I want to perform some filtering on it before supplying the audio directly to an audio queue.
Is this possible on iPhone?
If so, can anyone tell me how I would access the aud开发者_开发技巧io file directly? Is it just a matter of using the "URL" to load it using NSFile (Presumably I obtain that through MPMediaItemPropertyAssetURL)? Or do I need to do something more complicated?
Cheers!
The URL you get from MPMediaItemPropertyAssetURL
is an Assets Library URL. You can use it to initialize an AVURLAsset
. Then create an AVAssetReader
with the asset and add to it an AVAssetReaderOutput
(instances of AVAssetReaderAudioMixOutput
or AVAssetReaderTrackOutput
, depending on what you need). This latter object will finally give you access to the media data (-copyNextSampleBuffer
).
精彩评论