加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Swift:如何以编程方式设置iphone卷

发布时间:2020-12-14 05:27:55 所属栏目:百科 来源:网络整理
导读:参见英文答案 How to change device Volume on iOS – not music volume7个 How to change an iOS device volume programmatically?4个 我正在尝试创建一个警报应用程序,我注意到睡眠周期等应用程序会在警报响起之前将音量设置为最大,即使音量非常低. 我尝试
参见英文答案 > How to change device Volume on iOS – not music volume7个
> How to change an iOS device volume programmatically?4个
我正在尝试创建一个警报应用程序,我注意到睡眠周期等应用程序会在警报响起之前将音量设置为最大,即使音量非常低.

我尝试过使用AVAudioPlayer,我在MPVolumeView上看到的只是用户必须这样做.
有没有办法在没有用户必须的情况下将其打开?

谢谢您的帮助.

如果我可以请快速获取代码

您只需要导入MediaPlayer.你可以这样做:
import MediaPlayer

并将音量设置为最大值

(MPVolumeView().subviews.filter{NSStringFromClass($0.classForCoder) == "MPVolumeSlider"}.first as? UISlider)?.setValue(1,animated: false)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读