有没有办法通过iOS 7中的代码关闭手机上的铃声(使iPhone静音)?

有没有办法通过iOS 7中的代码关闭手机上的铃声(使iPhone静音)?,第1张

概述有没有办法通过iOS 7中的代码关闭手机上的铃声(使iPhone静音)? AppStore中有一个应用程序,我发现它具有关闭手机铃声的逻辑,即使iPhone铃声开关设置为开启. https://itunes.apple.com/us/app/silentalert/id506092189?mt=8 某些代码或某些参考资料受到高度赞赏.我经历了许多Stack-overflow post而没有太大的成 有没有办法通过iOS 7中的代码关闭手机上的铃声(使iPhone静音)?

AppStore中有一个应用程序,我发现它具有关闭手机铃声的逻辑,即使iPhone铃声开关设置为开启.
https://itunes.apple.com/us/app/silentalert/id506092189?mt=8

某些代码或某些参考资料受到高度赞赏.我经历了许多Stack-overflow post而没有太大的成功.

解决方法 首先,你能说明你已经尝试过的东西,而你却无法工作吗?

另请参阅this related and possibly duplicate StackOverflow Question.其中说这是不可能的,然后提到Apple AppStore不会批准的私有API.

有关私有API的更多信息,请参阅this StackOverflow Question.

具体来说,您需要从Celestial Private API或AVController中的setMuted调用toggleActivecategoryMuted,但这很可能会被Apple拒绝提交AppStore.

在阅读api文档的基础上,我相信引用的应用程序的工作方式是将AVAudioSessioncategory设置为AVAudioSessioncategoryAudioProcessing并使自己成为活动会话.

如果当应用程序变为后台并且您想要请求更多时间时,这不会继续静音,请参阅this StackOverflow Question.或者,请参阅this code example和supporting blogpost重复播放静音的内容.注意Apple应用程序商店评论显然也对此方法不满.代码实际上是一个更新的fork,应该在新的iOS版本上更好地工作.

它还具有作为后台应用程序,在后台播放音乐/静音以及处理中断的所有处理.使用位置服务可能是因为它可以使用(voID)locationManager:(CLLocationManager *)管理器dIDUpdateLocations:(NSArray *)位置来使用区域监视或重要更改位置服务来触发应用程序重新启动.

这些概念的代码示例如下:

> Example music application that plays music in the background.我建议将ession类别更改为AVAudioSessioncategoryAudioProcessing并进行切换,将其切换回AVAudioSessioncategoryPlayback,看看会发生什么.
> Example of changing just the AVAudioSessionCategory
> Example of changing the AVAudioSessionCategory and setting the active session
> Session setup and interuption handling

参考文献:

> Playing and Recording Background Audio
> Audio Session – Ensuring audio playback continues when screen is locked
> Audio Session Programming Guide
> AVAudio Session Class Reference
> StackOverflow Answer to a different question which states that if not reset,no audio is played

总结

以上是内存溢出为你收集整理的有没有办法通过iOS 7中的代码关闭手机上的铃声(使iPhone静音)?全部内容,希望文章能够帮你解决有没有办法通过iOS 7中的代码关闭手机上的铃声(使iPhone静音)?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1074806.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存