Andreas Schweiger
Andreas Schweiger

Reputation: 67

AudioUnits and MPMusicPlayerController

My App is utilizing the AudioUnit functionality to produce short sounds for a metronome application. All is running fine.

Now I want to play an MP3 from the iTunes Lib on the Device and I use MPMusicPlayerController for it.

No probs until here, the MP3 plays fine. But afterwards I can never again invoke my AudioUnit sounds again. I debugged it that far that the callback for the Audio buffers never ever appears again so I think the AUGraph has been stopped but it signals that it is still running.

Anyone having an idea? Did the MPMusicPlayerController just stop the Graph? And how to prevent that?

Thanks for any hint, Andreas

Upvotes: 2

Views: 707

Answers (1)

tassock
tassock

Reputation: 1653

From this doc, "Music players (instances of the MPMusicPlayerController class) always use a system-supplied audio session." Your application can't access system-supplied audio sessions as far as I know. Therefore, it's not possible for MPMusicPlayerController audio and your app audio to be played simultaneously.

In order to play an MP3 from the iPod library and your metronome simultaneously, do the following:

  1. Set up an AUGraph with its own audio session
  2. Read the MP3's samples with AVAssetReader
  3. Feed samples to your AUGraph on one channel
  4. Mix in metronome audio on the other channel

Upvotes: 2

Related Questions