您能确定插入 iphone/ipad/ipod 耳机插孔的设备的具体类型吗?
在使用 iPad 及其耳机插孔时,我注意到一些有趣的事情。
当我将 iPhone 耳塞式耳机插入 iPad 时,我可以更改耳机音量(使用 iPad 上的音量按钮)。如果我拔下耳塞并使用同一耳机插孔插入外部扬声器,我可以再次将音量调节到不同的级别。如果拔掉扬声器,我可以重新插入耳塞。音量会自动变回我上次设置耳机的音量。如果我有第三个设备插入耳机插孔(在我的例子中,我使用插入耳机插孔的 UniMag 信用卡刷卡器进行了测试),iPad 会记住第三个卷。它似乎知道哪个设备插入了 iPhone 插孔并将其设置为适当的音量级别。
这与我的预期相反。我希望耳机插孔有一个音量级别,而不管插入的设备是什么。
如果 iPad 可以确定哪个设备是哪个设备,这也适用于我的本机应用程序吗?我能否判断用户是否使用某些音频 API 将耳机、外部扬声器或 UniMag 信用卡刷卡设备插入耳机插孔并做出相应的行为?
另外,如果你知道 iPad 识别哪个设备的能力背后的技术机制,那对我来说也会很有趣。
我正在运行 iOS5 的 iPad2 上进行测试。
I have noticed something interesting when working with an iPad and its headphone jack.
I can change the head phone volume (using the volume buttons on the iPad) when I plug in my iPhone earbud headphones into the iPad. If I unplug the earbuds and plug in external speakers using the same headphone jack, I can adjust the volume again, to a different level. If I unplug the speakers, I can replug in the earbuds. The volume automatically changes back to the volume that I had last set the earbuds to. If I have a third device that plugs into the headphone jack (in my case, I tested with a UniMag credit card swipe reader which plugs into the headphone jack) the iPad remembers yet a third volume. It seems to know which device is plugged into the iphone jack and set it to the appropriate volume level.
This is counter to what I expected. I expected there to be one volume level for the headphone jack, without regard to what device is plugged into it.
If the iPad can determine which device is which, is this also available to my native app? Can I tell if the user plugs head phones, external speakers, or a UniMag credit card swipe device into the headphone jack using some Audio API and behave accordingly?
For bonus, if you know the technical mechanism behind the iPads ability to identify which device is which, that would be interesting to me as well.
I am testing on an iPad2 with iOS5.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 CoreAudio 来实现此目的。我相信您也可以设置更改通知。更具体地说,您可以在 iOS 上使用音频会话来执行此操作。您正在寻找的是路线变更。 https://developer.apple.com/库/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html
You can use CoreAudio for this purpose. I believe you can set up notifications for changes too. More specifically you can do this on iOS with Audio Sessions. What you're looking fo is route changes. https://developer.apple.com/library/ios/#documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html