How to determine the current level of the iPhone ringer?

痴心易碎 提交于 2019-12-05 02:07:45

问题


I'm silencing the iPhone ringer with AVSystemController, but I don't know how to determine the current level of the ringer. Any ideas?

PS Yes I know that using AVSystemController might get the app banned from the App Store. It's not an issue.


回答1:


You cannot change device volume programatically, however MPVolumeView (volume slider) is there to change device volume but only through user interaction, like making your own slider and labeling it 'volume' or something.

MPVolumeView is a control in toolbox, you need to add MediaPlayer.framework in your project then MPVolumeView will be displayed in toolbox in interface builder. MPVolumeView uses device volume, including ringing volume. AVAudioPlayer is only for application level volume.

Also, there is a little thing you can do:

  musicPlayer = [[MPMusicPlayerController iPodMusicPlayer];
  musicPlayer.volume = 1; // device volume will be changed to maximum value

Hope this helps.



来源:https://stackoverflow.com/questions/7946246/how-to-determine-the-current-level-of-the-iphone-ringer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!