AVAudioPlayer playing Sound with very low volume in iPhone 6 and 6+
The volume is low because the sound is coming via the top speaker in iPhone(used for calling).
You have to override the AVAudioSession out put port to the main speaker.(bottom speaker)
This is the code that Route audio output to speaker
AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, error: &error)
Swift 3.0:
do {
try AVAudioSession.sharedInstance().overrideOutputAudioPort(AVAudioSessionPortOverride.speaker)
} catch _ {
}
Solution for Swift 4
try? session.setCategory(.playAndRecord, mode: .default, policy: .default, options: .defaultToSpeaker)
P.S. For full class you can check my gist