多久我会在后台运行一个计时器? [英] How long i will run a timer in background?

查看:345
本文介绍了多久我会在后台运行一个计时器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序正在运行在后台的定时器每8秒打一个自定义的声音,它工作正常,但在稍后的某个时候得到停止,所以我怎样才能在后台持续播放的声音?
目前我使用下面的code在后台播放声音

In my application i am running a timer in background for every 8 seconds to play a custom sound,it works fine ,but it get stops at later sometime,so how can i play the sound continuously in background? Currently i am using the below code to play the sound in background

      SystemSoundID soundID;
        AudioServicesCreateSystemSoundID((__bridge CFURLRef)filePath, &soundID);
        AudioServicesPlaySystemSound(soundID);

让我知道了很好的解决了在后台持续播放声音

let me know the good solution to play the sound continuously in background

推荐答案

简短的回答:您的应用程序只是暂停

Short answer: your app is simply suspended.

龙答案:你缺少后台精明实施的关键部分。

Long answer: You are missing key parts of the background savvy implementation.


  1. 您需要告诉你是的音频应用的,和悬浮当您要求额外的周期了iOS。

  2. UIBackgroundModes 必须报经批准

  1. You need to tell the iOS that you are an Audio App, and that you are requesting extra cycles when suspended.
  2. The UIBackgroundModes is subject to approval

从<一个href=\"https://developer.apple.com/library/ios/documentation/iphone/conceptual/iphoneosprogrammingguide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html#//apple_ref/doc/uid/TP40007072-CH4-SW20\"相对=nofollow>文档:

的应用背景模式:
UIBackgroundModes 值= 音频

该应用播放音频内容到背景中的用户或记录的音频时。 (此内容包括流式音频,或者使用AirPlay的视频内容。)

如果您的应用程序不属于以下任何一个类别的,那么你唯一的选择延长一个后台超越典型的 5 秒是调用 -beginBackgroundTaskWithName:expirationHandler:。你很可能会 30 秒左右的时间内暂停。

If your app does not fall into any of the categories below, then your only option to extend backgrounding beyond the typical 5 seconds is to invoke -beginBackgroundTaskWithName:expirationHandler:. You will likely be suspend within 30 seconds or so.


  • 音频

  • 位置

  • VOIP

  • 报摊含量

  • 外部附件

  • 蓝牙中央和放大器;蓝牙外设


  • 远程通知

这篇关于多久我会在后台运行一个计时器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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