ios - Multiple AVPlayers ducking? -
i have relatively simple setup involving 1 avplayer looping ambient audio in background , second player playing shorter sound @ points.
what i've observed when short sound played, hear ambient clip cut out second while there staticy pop. proceeds continue playing while short sound played @ same time. happens on device - it's not noticeable on sim, seems point potential performance issue.
i can't quite figure out why first avplayer has blip. here code ambient player:
nsstring *path = [[nsbundle mainbundle] pathforresource:kambienttrack oftype:@"mp3"]; _ambientplayer = [avplayer playerwithurl:[nsurl fileurlwithpath:path]]; [self.ambientplayer play];
it's more complex, listen notification when ends , restart it, issue happens during initial play before looping occurs.
so while going in background, play clip so:
self.announcementplayer = [[avplayer alloc] initwithurl:[myobject audiopathurl]]; [self.announcementplayer play];
so nothing unique there - 2 avplayers playing.
the other piece of interest how set audio session when app launches.
[[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayback withoptions:avaudiosessioncategoryoptionmixwithothers error:nil];
i'm doing allow user play music other apps in background.
i think code pretty straight forward, , have no idea why getting blip.
i fixed changing audio players avaudioplayers. resolved popping in cases. however, still ducking. specifically, if play avaudioplayer and, while it's still playing, start load avplayer, cuts off avaudioplayer second. here's i'm talking about:
[myavaudioplayer play]; avplayer *player = [avplayer playerwithurl:[self.currentexercise videopathurl]];
the addition of second line causes first second or of myavaudioplayer silent.
Comments
Post a Comment