vendredi 13 février 2015

iOS play .m4a sound file while music is playing in the background [duplicate]


This question already has an answer here:




When I play an .m4a sound file with music playing from the iTunes library the music stops and then the sound plays. How can I get the sound to play over the music?



NSString *path = [NSString stringWithFormat:@"%@/sound.m4a", [[NSBundle mainBundle] resourcePath]];
NSURL *soundUrl = [NSURL fileURLWithPath:path];

NSError *error;

_avp = [[AVAudioPlayer alloc] initWithContentsOfURL:soundUrl error:&error];

_avp.volume =1.0;

[_avp prepareToPlay];
[_avp play];

Aucun commentaire:

Enregistrer un commentaire