在后台停止音频 [英] stop audio while in background

查看:69
本文介绍了在后台停止音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个名为IHeartRadio的应用程序,可让您设置睡眠计时器,该计时器将在指定的时间间隔后关闭音频.

There is an app called IHeartRadio which lets you set a sleep timer which will shut off audio after a specified interval.

您首先选择一个要收听的电台,然后选择一段睡眠时间,之后电台将停止播放.该应用程序无需成为前台即可.

You first choose a station to listen to and then select an amount of time to sleep after which the radio station will stop playing. The app does not need to be in the foreground for this to happen.

应用程序在后台时如何停止音频?

How is it possible for an app to stop audio while it is in the background?

一种理论是使用无声音频设置UILocalNotification.然后,UILocalNotification将接管设备的音频,实际上使正在播放的音频静音.那没用.

One theory was to set a UILocalNotification with silent audio. Then the UILocalNotification would take over the audio of the device, in effect silencing whatever audio was playing. That didn't work.

计时器在后台不起作用,就后台基于时间的行为而言,这没有多大作用.

Timers don't work in the background, which doesn't leave much in terms of time-based behavior in the background.

推荐答案

当UIBackgroundModes键包含音频值时,系统的媒体框架会自动防止相应的应用移至后台后被挂起.只要它正在播放音频或视频内容,该应用程序就会继续在后台运行.但是,如果该应用停止播放音频或视频,则系统会暂停它.

来自 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆