What happens to an iPhone app when iPhone goes into stand-by mode?

后端 未结 6 832
忘掉有多难
忘掉有多难 2020-12-02 07:21

My app uses NSTimer and it appears that NSTimer doesn\'t fire when the iPhone goes into the stand-by mode (either by pressing the hardware button or by the idle timer).

6条回答
  •  醉酒成梦
    2020-12-02 07:39

    I used the information on this post for a small sample that I was building. This is the code that I used when I initiated the playback to prevent the audio from stopping:

    AudioSession.Category = AudioSessionCategory.MediaPlayback;
    

    And when the application is done with the playback to reset to the original value:

    AudioSession.Category = AudioSessionCategory.SoloAmbientSound;
    

    The full sample is here:

    http://github.com/migueldeicaza/monotouch-samples/tree/master/StreamingAudio/

提交回复
热议问题