- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我运行的是 iOS 4.3.2。
或者:
这是我的 Audio Session 代码:
@implementation AudioSession
+ (void) CreateAudioSessionWithInterruptionListener: (AudioSessionInterruptionListener) interruptionListener
returningSampleRate: (Float64 *) pHWSampleRate
{
OSStatus result = AudioSessionInitialize(NULL, NULL, interruptionListener, self);
if (result != kAudioSessionNoError)
{
NSLog(@"AudioSessionInitialize(...) failed!");
return;
}
SET_PROPERTY( kAudioSessionProperty_AudioCategory, UInt32, kAudioSessionCategory_PlayAndRecord );
SET_PROPERTY( kAudioSessionProperty_OverrideCategoryMixWithOthers, UInt32, (UInt32) YES );
SET_PROPERTY( kAudioSessionProperty_PreferredHardwareIOBufferDuration, Float32, .005 );
// GET not set h/w sampleRate
// Float64 hwSampleRate;
// UInt32 size = sizeof(Float64);
AssertOK(AudioSessionGetProperty(
kAudioSessionProperty_CurrentHardwareSampleRate,
& (UInt32) { sizeof(Float64) },
pHWSampleRate),
@"couldn't get hw sample rate");
//NSAssert(size == sizeof(Float64);
NSLog(@"H/W SampleRate: %d", (int) (* pHWSampleRate));
AssertOK(AudioSessionSetActive(true),
@"couldn't set audio session active\n");
}
最佳答案
这实际上可能是一个 iOS 错误。切换到 HDMI 输出(也是 iOS 4.3)时,我遇到了同样的问题。在 50% 的所有情况下,路由更改成功并且音频从电视而不是 iPad 中传出,正如预期的那样。在所有其他 50% 的情况下,插入 HDMI 适配器后,我根本没有音频,既没有电视,也没有 iPad。再次拔下适配器后,我就恢复了音频。
所以我无法真正为您提供一个很好的解决方案,只能提供一个解决方案。注册音频路由更改(通过为属性 kAudioSessionProperty_AudioRouteChange 设置属性监听器)。当此回调触发时,处理它,例如通过重新初始化所有 Core Audio 的东西。这不是一个很好的解决方案,但却是一个可行的解决方案。
更新:
在您的特殊情况下,系统的行为与 Apple 所说的行为非常相似。让我引用 Apple 的 iOS 界面指南:
The case for playback is similar but has different outcomes, as shown on the right of the figure. If a user unplugs the headset during playback, your callback should pause the audio. If a user plugs in the headset during playback, your callback should simply allow playback to continue.
所以 Apple 说:从内置扬声器切换到耳机 -> 播放继续。从耳机切换到内置扬声器 -> 播放暂停。根据这句话,这是一种您应该自己实现的行为,而不是系统为您强制执行的行为,但它非常接近您实际看到的行为,不是吗?
关于ios - iPad 错误处理路由更改扬声器 -> 耳机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5818000/
当我看到 Square 使用 iPhone 上的耳机插孔发送信用卡数据后,我对此产生了兴趣。 iPhone、普通笔记本电脑和普通移动设备上耳机插孔的平均带宽是多少? 可以通过在不同 channel
在Mango中是否可以检测是否已连接耳机?我想根据用户是否已连接耳机来更新一些UI元素。 (我真正需要的是耳机中的麦克风) 谢谢你的建议 最佳答案 没有可用的API提供此信息。 您将无法在您的应用中做
我试图让用户能够在应用程序中切换音频输出,并且能够使用AVAudioSession在扬声器和扬声器之间切换,但是在任何情况下我都找不到在连接的蓝牙设备和耳机之间切换的方法订购。 谢谢您的帮助。 最佳答
我运行的是 iOS 4.3.2。 我在我的 iPad 上启动我的应用程序(没有插入电源)。 音频作品。 我插入耳机。 没有音频,iPad 和耳机都没有。 我拔下耳机,转到 (2) 或者: 我在插入耳机
是否可以判断耳机是否已插入Windows Phone 8设备上? 我想使用Text to Speech API,但我不想通过扬声器阅读消息 最佳答案 实际上,是的,您可以使用WP8。这不是一个显而易见
使用AudioUnit和kAudioUnitSubType_HALOutput如何检测输出是Speaker还是Headset? 最佳答案 bool usingInternalSpeakers() {
我的目标: 从我的Android应用程序检测附近的所有蓝牙设备(电话,耳机等)。 这是developer.android.com中的一个很好的示例,该示例发现附近的蓝牙设备以及已配对的设备列表。 我的
如标题,我想知道如何获得我的 voip 应用程序的可用输出声音路径列表,或重现默认的 IOS 效果。此时我可以在用户调用电话时启用/禁用扬声器,但如果用户连接了蓝牙耳机,我希望用户可以选择使用哪条路由
我在使用 AudioRecord 类时遇到一些问题。我有一个应用程序可以在有人通过耳机收听音频时录制音频。在这种情况下,它工作正常。用户可以毫无问题地进行录制。任何使用内置麦克风耳机的用户都无法录音。
是否可以将 Ocullus Rift 或 HTC Vive 等 VR 设备连接到智能手机?我想为 Android 和 iOS 平台开发 VR 应用程序,但使用外部 VR 耳机,例如 Oculus Ri
有没有办法在 java 中获取设备(扬声器、耳机)的 GUID?我正在尝试修改注册表中的特定值,例如我需要这个键名 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Wind
因此 iPhone 可以与蓝牙耳机配对并用它来调用电话(尽管使用 3.0 操作系统的 iPod Touch 无法与耳机配对,请看一下)。 但是我可以编写一个可以访问配对的蓝牙设备及其功能(例如耳机的麦
如何让服务监听 android 设备中的媒体按钮(耳机 Hook )。我尝试使用这段代码来做到这一点,但没有奏效。你能帮帮我吗。 服务代码: public class RLservice extend
想要的功能: 它类似于 iPhone 原生手机应用程序。当有蓝牙/耳机连接到 iPhone 时,扬声器按钮(通常只有扬声器/电话切换)将显示所有可用的音频输出设备。默认使用蓝牙。用户可以选择另一个设备
在我的 ipad 中,当我进入蓝牙设置页面时,我可以在已连接列表中看到我的三星耳机设备 (HM 1100)。但是,当我使用以下代码时,我无法获得任何配件。 NSArray *accessories =
我正在寻找一种方法来检测我的 VR 应用程序中使用的耳机名称。我需要区分 任务 1 & 2 为了实现不同的 Controller 映射。 XRDevice.model 或 OVRPlugin.prod
我有一些代码可以从相机捕捉镜头并输出拼接的 360 度视频。我可以将拼接视频输出为 MP4文件,RGBA文件,或 RGBA OpenGL纹理。 我需要以某种方式让我的代码将拼接的视频直播到 VR 耳机
我在 stackoverflow 中搜索我的问题的答案,我看到了很多信息,但我没有找到解决我的问题的方法。我尝试接收按钮诺基亚耳机蓝牙调用接收。 在 list 中我有:
我是一名优秀的程序员,十分优秀!