简体   繁体   中英

audio file not playing on iphone 5

My ios app plays few audio (.m4a) files . It works well and i hear the audio on ios simulator running on ios 7, but when i run the app on my iphone 5, ios 7, it does not play the audio. At least i don't hear anything.

I ran the app on iPhone 4s , os 6.3 and 7.0 and it worked well. Looks like the issue is something related to iPhone 5, maybe it is some setting in my phone ?

I did a similar post here but its not really helping me.
Audio file doesn't play in iPhone 5

In the play audio method, i have the following statements

I have audioPlayer loaded and ready to play on a swipe gesture

self.audioPlayer = [self getAudioPlayer:imgAudFileName extension:@".m4a"];
[self.audioPlayer prepareToPlay];

When the use clicks on play button, this is the action that gets executed

- (IBAction)playOrPauseSound:(UIButton *)sender {

    [self.audioPlayer play];
    BOOL isAudioPlaying = [self.audioPlayer isPlaying];
    NSLog(@" Audio Playing? %d", isAudioPlaying);
    [self.audioPlayer setDelegate:self];
}

which returns 1 for both Simulator and iPhone5

- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player
                   successfully:(BOOL)flag {
    NSLog(@" Did Finish Playing %d", flag);
}

delegate method is also returning 1 on iPhone 5..

Any help on this is appreciated.

Thanks,

Update : Nov-12 I tried using a different method to initialize and use AudioPlayer but the issue remains the same

- (IBAction)testAction:(id)sender {
    NSURL *url = [[NSBundle mainBundle] URLForResource:@"hello" withExtension:@"m4a"];
    _somePlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL];
    _somePlayer.delegate = self;
    [_somePlayer play];

}

I deployed the app on my friends iPhone 5, ios 7 and it worked there without any issues. I dont have a proper explanation for why it's not working on my phone. I guess I have to get it tested on more iphone 5.

Thanks,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM