Use system channel instead of call channel when using EPSSampler in iOS

I use EPSSampler to play some notes in my small iOS application. It works well, except that the sound is controlled by the ringer settings, not the system volume settings. The problem is that if the call is disconnected, my application does not make a sound.

The closest I could find was this SO question , but I cannot completely translate this solution into mine, since I cannot match it with the EPSSampler code. Any insight?

EDIT . To clarify, the only code that relates to audio is contained in the EPSSampler class, my application simply copies it, loads the AUSampler preset and calls the note playback methods in EPSSampler, so the solution will have to change something in EPSSampler, not in my application , - therefore I do not send the source code.

+6
source share
1 answer

It turns out that this has nothing to do with EPSSampler and everything with setting up an audio session. The following code did the trick.

NSError *error = nil;
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:&error];

This will teach me RTFM .

+4
source

All Articles