ios - AVAudioPlayer does not audibly play, throws no errors, calls no delegate method -
encountering weird issue. i'm trying use avaudioplayer play simple sound file disk. maintain strong reference via property arc doesn't kill prematurely. said in title, no sound, errors , no delegate methods called--including didfinishplaying (which expect). thing seems "happen" hear 2 quiet clicks...
now weird part...if set breakpoint before [_player play], step over, audio plays fine!! confirms me have set things correctly, , makes me think else stepping on shared avaudiosession thread? i'm not sure. total lack of delegate calls odd--it seems something should called whenever avaudioplayer finishes.
i using openears speech recognition, call suspendlistening on before attempting play audio. have tried disabling openears entirely, try , isolate cause--but had no effect, either. perplexing. appreciate help!
-(void)playaudionotewithpath:(nsstring *)filepath { nserror *error = nil; avaudiosession *audiosession = [avaudiosession sharedinstance]; [audiosession setcategory:avaudiosessioncategoryplayandrecord withoptions:avaudiosessioncategoryoptionallowbluetooth error:&error]; if (error) { dlog(@"error setting audio session category: %@", [error localizeddescription]); } nsurl *url = [nsurl urlwithstring:filepath]; if (!url) { dlog(@"no file path!!"); } _player = [[avaudioplayer alloc] initwithcontentsofurl:url error:&error]; if (error) { dlog(@"error initializing audio player: %@", [error debugdescription]); } _player.delegate = self; [_player preparetoplay]; // setting breakpoint here cause playback succeed. if (![_player play]) { dlog(@"error playing!!"); } }
well, seem have found fix, though i'm not sure why...since it's not code, moved calling class. calling class plays audionotes directly, instead of audionotes playing themselves. works.
Comments
Post a Comment