zoukankan      html  css  js  c++  java
  • ios 耳机插入拔出检测

    [AVAudioSession sharedInstance];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(audioRouteChangeListenerCallback:)
    name:AVAudioSessionRouteChangeNotification
    object:nil];

    - (void)audioRouteChangeListenerCallback:(NSNotification*)notification
    {
    NSDictionary *interuptionDict = notification.userInfo;

    NSInteger routeChangeReason = [[interuptionDict valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];

    switch (routeChangeReason) {

    case AVAudioSessionRouteChangeReasonNewDeviceAvailable:
    NSLog(@"AVAudioSessionRouteChangeReasonNewDeviceAvailable");
    NSLog(@"Headphone/Line plugged in");
    break;

    case AVAudioSessionRouteChangeReasonOldDeviceUnavailable:
    NSLog(@"AVAudioSessionRouteChangeReasonOldDeviceUnavailable");
    NSLog(@"Headphone/Line was pulled. Stopping player....");
    break;

    case AVAudioSessionRouteChangeReasonCategoryChange:
    // called at start - also when other audio wants to play
    NSLog(@"AVAudioSessionRouteChangeReasonCategoryChange");
    break;
    }
    }

  • 相关阅读:
    joomla
    笨兔兔的故事(下)
    wine乱码
    笨兔兔的故事(中)
    gedit中文乱码
    php不常用函数
    android配置开发环境ubuntu
    笨兔兔的故事(上)
    关于linux编码
    linux常用命令小记
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/7149203.html
Copyright © 2011-2022 走看看