AVAudioPlayer sound too low on both speaker and headphone

169 Views Asked by At

I have the following code which will play a sound buffer, but no matter what I tried, the volume still too low on both speaker and earphone even though system volume is already at max level. What wrong with my code?

-(void)playSound:(NSData *)data {
    NSError* error;
    player = [[AVAudioPlayer alloc] initWithData:data error:&error];

    if (error) {
        // TODO: log error
    }
    [player setNumberOfLoops:0];
    [player setVolume:1.0f];
    player.delegate = (id)self;
    [soundArray insertObject:player atIndex:0];
    [player prepareToPlay];
    [player play];
}
0

There are 0 best solutions below