Question

What do you think is the best (i.e. most memory efficient) way of playing a few 30 second audio files (m4v) from the bundle within an app to the external speaker? The audio files have to play automatically as soon a specific view appears.

There is no mixing, etc. going on. However I'm listening to the microphone at the same time via AVAudioRecorder to measure a few noise levels/peak sounds etc. and react to them.

Thanks!

Was it helpful?

Solution

m4v are video files. Did you mean m4p?

Assuming you did, I'd say start with AVAudioPlayer

Since you're using input at the same time as playback, you'll want to set your Audio Session's category appropriately:

[AVAudioSession sharedInstance].category = AVAudioSessionCategoryPlayAndRecord;

// note that on the iPhone that category will send audio output to the 
// phone earpiece rather than the speaker, so you have to redirect the output
// like so:

UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;

AudioSessionSetProperty (
    kAudioSessionProperty_OverrideAudioRoute,
    sizeof (audioRouteOverride),             
    &audioRouteOverride                      
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top