上传时prevent空闲状态(在iOS上的Web应用程序) [英] Prevent idle state when uploading (web app on iOS)

查看:142
本文介绍了上传时prevent空闲状态(在iOS上的Web应用程序)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建设将在移动和桌面使用的Web应用程序,并测试在iOS后,我发现我的手机将进入空闲状态(屏幕关闭,presented与锁屏在返回),即使有被上载的文件(AJAX上传)。有没有什么办法prevent这种情况的发生?

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?

我运行它作为一个家筛选的Web应用程序测试的应用程序,如果有差别。(即您保存在主屏幕网站)

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.

推荐答案

本来我无法找到一个答案(最可能是由于我的特殊问题的措辞),但我最终加入以下到我的上传

Originally I couldn't find an answer to this (most likely due to my particular phrasing of the question), but I ended up adding the following to my upload modal which prevented my phone from sleeping while the modal was open (only tested on 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/

这篇关于上传时prevent空闲状态(在iOS上的Web应用程序)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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