zoukankan      html  css  js  c++  java
  • iOS电话等中断事件的开始和结束通知

    #import "ViewController.h"
    
    #import <AVFoundation/AVFoundation.h>
    
     
    
    @interface ViewController ()
    
     
    
    @end
    
     
    
    @implementation ViewController
    
     
    
    - (void)viewDidLoad {
    
        [super viewDidLoad];
    
        // Do any additional setup after loading the view, typically from a nib.
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleAudioSessionInterruptNoti:) name:AVAudioSessionInterruptionNotification object:[AVAudioSession sharedInstance]];
    
    }
    
    //音频播放中断的通知
    
    -(void)handleAudioSessionInterruptNoti:(NSNotification*)noti
    
    {
    
        NSDictionary *userInfo = noti.userInfo;
    
        AVAudioSessionInterruptionType type = [userInfo[AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
    
        switch (type)
    
        {
    
            case AVAudioSessionInterruptionTypeBegan:
    
            {
    
                //需要停止播放操作
    
            }
    
                break;
    
            case AVAudioSessionInterruptionTypeEnded:
    
            {
    
                AVAudioSessionInterruptionOptions options = [userInfo[AVAudioSessionInterruptionOptionKey] unsignedIntegerValue];
    
                if (options == AVAudioSessionInterruptionOptionShouldResume)
    
                {
    
                    //需要执行播放操作
    
                }
    
            }
    
                break;
    
            default:
    
                break;
    
        }
    
    }
    
     
  • 相关阅读:
    MDX函数
    OLAP + MDX
    AIOps指导
    ES Terms 聚合数据不确定性
    redis初步入门
    java写hadoop全局排序
    [工程技巧]
    python与字符集编码
    转载python2进制打包相关
    转载 大端VS小端
  • 原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/8482124.html
Copyright © 2011-2022 走看看