有一个名为 IHeartRadio 的应用程序,可让您设置睡眠计时器,该计时器将在指定的时间间隔后关闭音频。
您首先选择要收听的电台,然后选择睡眠时间,之后广播电台将停止播放。应用程序不需要位于前台即可发生这种情况。
应用程序如何在后台停止音频?
一种理论是设置带有静音音频的 UILocalNotification。然后 UILocalNotification 将接管设备的音频,实际上使正在播放的任何音频静音。那行不通。
计时器不在后台工作,这不会在后台留下太多基于时间的行为。
When the UIBackgroundModes key contains the audio value, the system’s media frameworks automatically prevent the corresponding app from being suspended when it moves to the background. As long as it is playing audio or video content, the app continues to run in the background. However, if the app stops playing the audio or video, the system suspends it.
From iOS 应用程序编程指南 http://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW24.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)