iOS use the volume buttons as input(iOS 使用音量按钮作为输入)
问题描述
我最近下载了一个应用程序,它使用音量 -"按钮切换值,并使用音量 +"按钮开始/停止视频录制.该应用名为 SloPro,可在应用商店中找到.我认为不允许修改 iPhone 硬件的行为.关于如何做到这一点的任何想法?
I've recently downloaded an app that uses the 'Volume -' button to toggle a value, and it uses the 'Volume +' button to start/stop recording of video. The app is called SloPro, and can be found in the app store. I thought it wasn't allowed to modify the behaviour of the iPhone's hardware. Any ideas on how this is done?
推荐答案
参见Audio Session Services References 了解更多详细信息,但基本上您使用 AudioSessionInitialize
开始一个音频会话.然后使用 AudioSessionSetActive
使其处于活动状态.然后使用 AudioSessionAddPropertyListener
监听音量的变化,您可以在其中传递类型为 AudioSessionPropertyListener
的回调.
See the Audio Session Services References for more details, but basically you start an audio session with AudioSessionInitialize
. Then you make it active with AudioSessionSetActive
. Then listen for changes in the volume with AudioSessionAddPropertyListener
where you can pass a callback that has type AudioSessionPropertyListener
.
查看以下网站以获取示例:http://fredandrandall.com/blog/2011/11/18/taking-control-of-the-volume-buttons-on-ios-like-camera/
Check the following website out for an example: http://fredandrandall.com/blog/2011/11/18/taking-control-of-the-volume-buttons-on-ios-like-camera/
这篇关于iOS 使用音量按钮作为输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:iOS 使用音量按钮作为输入


基础教程推荐
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01