检测(听)iOS 7 中的音频路由变化 [英] Detect (listen to) audio route change in iOS 7

查看:51
本文介绍了检测(听)iOS 7 中的音频路由变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚开始为iOS 7开发,发现iOS 7中不推荐使用AudioSession相关的函数和PropertyListeners.

Just starting development for iOS 7, and found that AudioSession related functions and PropertyListeners are deprecated in iOS 7.

在我使用以下方法检测耳机是否已插入或从设备拔出之前:

Before I use the following method to detect if a headset has been plugged in or unplugged from the device:

    /* add callback for device route change */
    AudioSessionAddPropertyListener (
                                     kAudioSessionProperty_AudioRouteChange,
                                     audioRouteChangeListenerCallback,
                                     (__bridge void *)(self));

然后实现监听器回调对内部算法做不同的事情.现在 iOS 7 已弃用它,并且没有任何替代方案的文档,这里有专家提供的任何解决方案吗?谢谢!

Then implement the listener callback to do different things to the internal algorithms. Now iOS 7 deprecated it and there's no documentations on any alternative, Is there any solutions by experts here? Thanks!

推荐答案

处理通知 AVAudioSessionRouteChangeNotification(适用于 iOS 6.0 及更高版本.)

Handle the notification AVAudioSessionRouteChangeNotification (Available in iOS 6.0 and later.)

这篇关于检测(听)iOS 7 中的音频路由变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆