1

I'm developing a mobile application to record audio. Functionality as follows. There is one static audio file on my application (which plays drum sound). When user start recording he can play this drum sound and start speaking/singing. Here I'm facing a problem with the static sound, when the recording is done and the user play back the same recorded audio file the static audio file sound (Drum sound in my case) is not audible properly like the way how user voice audible. If I can route the static audio file sound to the iPhone speaker even ear phone plugged in that will solve the problem. Can any one please help me how can I force play audio through speaker even though ear phone plugged in ? Thank you so much,

  • possible duplicate of [Force play audio file through iPhone speakers?](http://stackoverflow.com/questions/5264506/force-play-audio-file-through-iphone-speakers) – dandan78 Aug 14 '14 at 06:57
  • Dandan, I have tried with that options mentioned on the question chain. but no luck. – Bharath Reddy Aug 14 '14 at 07:01

2 Answers2

0

You can try this, it solves my problem.

AVAudioSession *audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil];
piet.t
  • 11,718
  • 21
  • 43
  • 52
0

Try this,

    do {
        try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.Speaker)
    } catch _ {

    }
Chandan
  • 747
  • 7
  • 17