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(handleAudioSessionRouteChangeNoti:) name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
    }
    //音频播放中断的通知
    -(void)handleAudioSessionRouteChangeNoti:(NSNotification*)noti
    {
        NSDictionary *userInfo = noti.userInfo;
        AVAudioSessionRouteChangeReason reason = [userInfo[AVAudioSessionRouteChangeReasonKey] unsignedIntegerValue];
        if (reason == AVAudioSessionRouteChangeReasonOldDeviceUnavailable)
        {
            AVAudioSessionRouteDescription *previousRoute = userInfo[AVAudioSessionRouteChangePreviousRouteKey];
            AVAudioSessionPortDescription *previousOutput = previousRoute.outputs[0];
            NSString *portType = previousOutput.portType;
            if ([portType isEqualToString:AVAudioSessionPortHeadphones])
            {
                //原来使用的设备是耳机,现在不再使用耳机需要进行的操作
            }
        }
        
    }
  • 相关阅读:
    中值滤波与图像锐化
    空间域图像增强
    图像的几何变换
    Fourier分析应用
    Gale-Shapley算法
    有理数与无限循环小数
    线性可分支持向量机
    拉格朗日乘子法+KKT条件
    点到平面的距离
    BP神经网络
  • 原文地址:https://www.cnblogs.com/yuxiaoyiyou/p/8482251.html
Copyright © 2011-2022 走看看