objective c - The app crashes when audio is playing and the device receives a phone call -
the app crashes when audio playing , device receives phone call. when hang call , return application, blocked.
code:
    nsurl *audiofilelocationurl;     nsstring *myaudiostring;     myaudiostring = @"my-audio";     audiofilelocationurl = [[nsbundle mainbundle]     urlforresource:myaudiostring withextension:@"mp3"];     nserror *error;     audioplayer = [[avaudioplayer alloc] initwithcontentsofurl:audiofilelocationurl error:&error];     [audioplayer setnumberofloops:1];     [nstimer scheduledtimerwithtimeinterval:.1 target:self selector:@selector(updatemyprogress) userinfo:nil repeats:yes];     if (error) {          nslog(@"%@", [error localizeddescription]);       } else {           [[avaudiosession sharedinstance] setcategory:avaudiosessioncategoryplayback error:nil];          [[avaudiosession sharedinstance] setactive: yes error: nil];           [audioplayer preparetoplay];          [audioplayer setdelegate:self];          [audioplayer play];      } 
done:
    - (void)audioplayerbegininterruption:(avaudioplayer *)player 
Comments
Post a Comment