如何以编程方式更改iOS设备的音量? [英] How to change an iOS device volume programmatically?
问题描述
是否可以通过编程方式更改设备音量?也许使用音频会话?
Is there a way to change the device volume programmatically? maybe using audio session?
推荐答案
我非常确定不可能控制实际设备的音量(因为这也有些麻烦)控制正在播放的某些媒体是另一回事.但是,您可以查看MPVolumeView
: https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPVolumeView_Class/index.html 用于显示用于设置音量的视图.
I'm pretty sure that it is not possible to control the actual device volume (as this would also be a bit obtrusive) Controlling some media you're playing is another thing. You could however look into MPVolumeView
: https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPVolumeView_Class/index.html for displaying a view for setting the volume.
这里也讨论了这个问题: 如何在iOS上更改设备音量-而不是音乐音量
The question has also been discussed here: How to change device Volume on iOS - not music volume
这篇关于如何以编程方式更改iOS设备的音量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!