0

I'm building a web application that will be used on mobile and desktop, and after testing on iOS, I've noticed that my phone will go into an idle state (screen turns off, presented with lock screen on return) even if there is a file being uploaded (ajax upload). Is there any way to prevent this from happening?

I'm testing the app by running it as a 'home-screened' web app (ie. a website you've saved to the home screen) if that makes a difference.

4

1 回答 1

1

最初我找不到这个问题的答案(很可能是由于我对问题的特定措辞),但我最终在我的上传模式中添加了以下内容,这阻止了我的手机在模式打开时进入睡眠状态(仅在 iOS7 上测试过):

<div style="display:none">
   <audio id="prevent_sleep" style="display:none" src="prevent_sleep.mp3" onended="this.play();" controls loop autobuffer autoplay></audio>
</div>
//prevent_sleep.mp3 is a 10 second silent mp3 file

<script>
   window.onload = function() {
      var audioEl = document.getElementById("prevent_sleep");

      audioEl.load();
      audioEl.play();
   };
</script>

我在http://flax.ie/how-to-get-hidden-autoplaying-audio-in-html5-on-ios/找到的

于 2013-10-28T20:10:09.990 回答