如何设置在iPhone应用程序的硬件音量? [英] How do you set the hardware volume in an iPhone app?

查看:194
本文介绍了如何设置在iPhone应用程序的硬件音量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

某些iPhone应用程序,如潘多拉似乎直接操作硬件体积和到物理音量按钮作出响应。如何做到这一点?

Some iPhone applications, such as Pandora seem to directly manipulate the hardware volume and respond to physical volume button. How is this done?

AudioSessionServices可以让你获得与 kAudioSessionProperty_CurrentHardwareOutputVolume 属性的当前硬件输出音量,但它是(可能)是只读的。

AudioSessionServices allows you to get the current hardware output volume with the kAudioSessionProperty_CurrentHardwareOutputVolume property, but it is (allegedly) read-only.

推荐答案

他们用MPVolumeView,简单的添加它,它使其余的,当用户触摸它。注:在iPhone模拟器不工作。我认为,发行说明中也提到不使用它在Interface Builder中直接。

They use the MPVolumeView, simple add it and it's makes the rest when the user touch it. Note: Doesn't work in iPhone Simulator. I think the release note also mentioned do not use it direct in Interface Builder.

MPVolumeView *volumeView = [[MPVolumeView alloc] initWithFrame:CGRectMake(25, 378, 270, 30)];
[self.view addSubview:volumeView];
[volumeView release];

这篇关于如何设置在iPhone应用程序的硬件音量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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