iOS检测耳机插入拔出
首先,需要导入两个框架
然后,注册通知检测耳机的插入与拔出操作
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(outputDeviceChanged:)name:AVAudioSessionRouteChangeNotification object:[AVAudioSession sharedInstance]];
[[NSNotificationCenter defaultCenter]postNotificationName:AVAudioSessionRouteChangeNotification object:self];
通知方法
- (void)outputDeviceChanged:(NSNotification *)aNotification {
AVAudioSessionRouteDescription* route = [[AVAudioSession sharedInstance] currentRoute];
for (AVAudioSessionPortDescription* desc in [route outputs]) {
if ([[desc portType] isEqualToString:AVAudioSessionPortHeadphones])
NSLog(@"有耳机");
else{
NSLog(@"没有耳机");
}
}
}
iOS检测耳机插入拔出的更多相关文章
- iOS 检测耳机插入/拔出
http://www.verydemo.com/demo_c134_i28481.html 开发过程中录音和播放这块碰到了一些问题,麻烦的主要有三个: 检测是否有声音输入设备 当有多个声音输出设备时, ...
- IOS 判断耳机插入/拔出
一. 方式 1.注册监听 //注册监听耳机设备的插入/拔出 AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChang ...
- ios 耳机插入拔出检测
[AVAudioSession sharedInstance]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@se ...
- Android -- 检测耳机插入状态
原理 其实android系统在耳机 ...
- windows10 声音图标总是被禁用,检测显示:扬声器,耳机或者耳机已拔出
参考来源:http://jingyan.baidu.com/article/90bc8fc85de19df652640c7f.html 控制面板/应用和声音/Realtek高清晰音频管理器 点击右上角 ...
- U盘插入拔出提示
Unit Unit1; Interface Uses Windows, Messages, SysUtils, Variants, classes, Graphics, Controls, Forms ...
- window 7喇叭有红叉,耳机扬声器已拔出驱动无法修复
win7系统没声音前提是声卡驱动已经安装完全,且没有问题.Windows 7系统电脑有耳机的存在,但是还是显示扬声器耳机或耳机已拔出 ,未修复故障,首先可以百度下看下其他教程,尝试过还是不行的时候,可 ...
- Delphi 自动检测U盘插入、拔出及获取U盘盘符!
http://qqhack8.blog.163.com/blog/static/1141479852012102133475/ Delphi 自动检测U盘插入.拔出及获取U盘盘符! u盘的 插 ...
- 广播监听USB插入与拔出
package com.joy.usbbroadcastreceiver; import android.content.BroadcastReceiver; import android.conte ...
随机推荐
- cogs——1001. [WZOI2011 S3] 消息传递
1001. [WZOI2011 S3] 消息传递 ★★ 输入文件:messagew.in 输出文件:messagew.out 简单对比时间限制:1 s 内存限制:128 MB Prob ...
- easyUi 学习笔记 (一) 使用easyui 和ztree 创建前端框架
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- dtrace-conf 2016
https://www.joyent.com/about/events/2016/dtrace-conf
- 一步步搭建java信息管理系统00 - 前言
开发前,先上效果图吧 信息管理系统,个人认为,以下几个因素是不可缺少的 多tab 因菜单比较多,右侧的树形一定要考虑,如果菜单还是多,那么顶部就要考虑起来了 以后想到什么,再添加吧. 看到easyui ...
- delphi异步选择模型编程TCP
Server端: unit U_FrmServer; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, ...
- 连接App.config
ConfigurationManager.AppSettings["AdminName"]; 连接App.config的字符
- shell脚本 加密备份MySQL数据库
1.加密备份为.bak文件(实际只是个.zip文件) #!/bin/bash # $:IP地址 # $:用户名 # $:数据库密码 # $:数据库名 # $:加密密码 # $:备份文件名 mysqld ...
- Restful WebService简介
RESTful Web Services已经渐渐開始流行, 主要是用于解决异构系统之间的通信问题.非常多站点和应用提供的API,都是基于RESTful风格的Web Services,比較就有Googl ...
- jeasyUI treegrid 的 reload 和 getChanges
看上去,treegrid继承自datagrid,因此,datagrid有的,treegrid也会有. 比如说,getChanges,翻看那些网络教程,绝大多数都没提treegrid有这个东东.但是,t ...
- Apache2.2安装
貌似Apache官网从2.2.X之后不再发布Windows安装版本,需要的话得自己编译 从官网下载2.2.25(我下了一个no-ssl的),安装提示 因为本机已经安装IIS,占用80端口,修改Apac ...