objective c - Playing AVAudioPlayer and SystemSoundID -


i building game sprit kit , i'm using continuous loop of sound using avaudioplayer in didmovetoview method. i'm using 4 other sounds using systemsoundid, have been created outside of didmovetoview method. problem when play game sound playing using avaudioplayer seems drown out other sounds have using systemsound. use avaudio of sounds seem work fine, slows game down little. wondering if there alternative or fix this? forgot mention seems problem when plug earphones in works fine when played without.

here code:

- (void)didmovetoview:(skview *)view   nsurl *playsound = [nsurl fileurlwithpath:[[nsbundle mainbundle]pathforresource:@"junglesound" oftype:@"wav"]];  nserror *error;  player = [[avaudioplayer alloc]initwithcontentsofurl:playsound error:&error];  [player play];  player.numberofloops = -1;  //continuous play// 

and outside of method

nsstring *soundpath = [[nsbundle mainbundle] pathforresource:@"jump2" oftype:@"wav"]; systemsoundid soundid; audioservicescreatesystemsoundid((__bridge cfurlref)[nsurl fileurlwithpath: soundpath], &soundid); audioservicesplaysystemsound(soundid);   nsstring *soundpath2 = [[nsbundle mainbundle] pathforresource:@"squish" oftype:@"wav"]; systemsoundid soundid2; audioservicescreatesystemsoundid((__bridge cfurlref)[nsurl fileurlwithpath: soundpath2], &soundid2); audioservicesplaysystemsound(soundid2);   nsstring *soundpath3 = [[nsbundle mainbundle] pathforresource:@"powerup3" oftype:@"wav"]; systemsoundid soundid3; audioservicescreatesystemsoundid((__bridge cfurlref)[nsurl fileurlwithpath: soundpath3], & soundid3); audioservicesplaysystemsound(soundid3); 

turning volume in ringer , alerts under settings solved problem.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -