Advertisement
Guest User

Untitled

a guest
Mar 27th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (void)handleAudioSessionInterruption:(NSNotification *)notification
  2. {
  3.         NSNumber *interruptionType = [[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey];
  4.         NSNumber *interruptionOption = [[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey];
  5.  
  6.         switch (interruptionType.unsignedIntegerValue)
  7.         {
  8.                 case AVAudioSessionInterruptionTypeBegan:
  9.                 {
  10.                         [_instreamAudioAd pause];
  11.                         break;
  12.                 }
  13.                 case AVAudioSessionInterruptionTypeEnded:
  14.                 {
  15.                         if (interruptionOption.unsignedIntegerValue == AVAudioSessionInterruptionOptionShouldResume)
  16.                         {
  17.                                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
  18.                                         [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategorySoloAmbient error:nil];
  19.                                         [[AVAudioSession sharedInstance] setActive:YES error:nil];
  20.                                         dispatch_async(dispatch_get_main_queue(), ^{
  21.                                                 [_instreamAudioAd resume];
  22.                                         });
  23.                                 });
  24.                         }
  25.                         break;
  26.                 }
  27.                 default:
  28.                         break;
  29.         }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement