ios - AVAudioSession Interruption notification fires only once -


in ios app i'm registering avaudiosession interruption notifications

[[nsnotificationcenter defaultcenter] addobserver:self selector:@selector(handleaudiosessioninterruption:) name:avaudiosessioninterruptionnotification object:nil];  [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayandrecord withoptions:avaudiosessioncategoryoptionallowbluetooth error:nil];  [[avaudiosession sharedinstance] setactive:yes error:nil]; 

when test app playing random music youtube, handleaudiosessioninterruption method fires first time (interruptionbegan). when quit youtube app, method gets fired again (interruptionended). repeat same steps before , method not fired @ , need restart app make work again. can tell wrong or point sample implementation.

note : neither see errors nor app crashes.

it's possible observer getting removed nsnotificationcenter. make sure that not happening. calling removeobserver:self without specifying notification name remove self nsnotificationcenter notifications.

also try making appdelegate observer of avaudiosessioninterruptionnotification in addition observer registering. if appdelegate's handler keeps getting called after other handler stops getting called give more information.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -