且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

HTML5的移动应用程序运行时,手机屏幕是关闭?

更新时间:2022-12-21 09:35:30

我的音乐应用程序是HTML5,也需要在后台运行。为支持的变化取决于手机浏览器。

My music app is HTML5 and also needs to run in the background. The support for that varies depending on mobile browser.

  • 在Safari浏览器在iOS:将继续在后台
  • 打一两首歌曲
  • 在Android原生浏览器:将播放一首歌曲,然后停止
  • 在火狐上的Andr​​oid版本:当将屏幕锁定或浏览器失去焦点或停止歌曲结束
  • 海豚在Android上:起着背景!但最终停止
  • 在歌剧上的Andr​​oid:更好的后台支持,Javascript的继续运行,音乐继续播放,即使屏幕关闭或Opera发送到后台,但最终经过几首歌停止
  • Safari on iOS: will continue to play one or two songs in the background
  • Native browser on Android: will play one song then stops
  • Firefox on Android: will stop when screen locks or browser loses focus or song ends
  • Dolphin on Android: plays in background! but eventually stops
  • Opera on Android: better background support, Javascript continues to run and music continues to play even when screen is off or Opera is sent to the background, but eventually stops after a couple songs.

正如你可以看到它的命中或错过。有一半的时间我最终试图把我的手机在倒退我的口袋里,试图保持在屏幕上,直到我无意中preSS它 - 完全吸收。我渴望当用户拥有更多的控制权在后台运行的应用程序的HTML5的一天。如果我猜我会说为,普遍的支​​持是很离谱,如果它甚至会牵引。我被压向尽管我几乎可以肯定,苹果将永远不会批准它本机应用程序的解决方案。在此期间,我将仍然相信,并保持测试最新的移动浏览器。因为如果实际发生这将是真棒。 : - )

As you can see it's hit or miss. Half the time I end up trying to put my phone in my pocket backwards, trying to keep the screen on, until I accidentally press it - totally sucks. I long for the day when the user has more control over running HTML5 apps in the background. If I had to guess I would say that universal support for that is very far off, if it ever even gets traction. I'm being forced toward a native app solution even though I am almost positive Apple will never approve it. In the meantime, I'll remain hopeful and keep testing the latest mobile browsers. Because if it actually happens it will be awesome. :-)

我还应该指出的是,在我的经验,为pretty的多少以上所有组合,使用HTML5同时运行JavaScript,拉网的数据,以及播放音乐一般将你的手机变成一个烤箱和杀死电池pretty的快。雪地。

I should also point out that, in my experience, for pretty much all of the above combinations, using HTML5 to simultaneously run javascript, pull network data, and play music will typically turn your phone into an oven and kill your battery pretty quickly. Ugg.

另外,如果你正在使用jQuery Mobile的(其中大部分是太棒了),你会看到不同的触摸操作在不同的浏览器。例如,火狐触摸的伟大工程,海豚是可怕的,需要precise触摸和保持和释放,以得到正确的。这不是直接HTML5的错,而是另外一个问题我负责的。

In addition, if you are using jQuery Mobile (which is mostly fantastic), you will see different touch handling on the different browsers. For example, Firefox touch works great, Dolphin is terrible and requires precise touch-and-hold-and-release to get right. That's not directly HTML5's fault, but another issue I'm dealing with.

下面是其他开发人员的有趣的想法的移动HTML5

Here are another developer's interesting thoughts on mobile HTML5.

更新:我刚刚(2013年5月22日)下载歌剧对我的三星Galaxy S3,它有***的HTML5的支持至今。对于我的应用程序,它继续在后台运行JavaScript时,屏幕是关闭或Opera推到后台,至少两首歌曲。

UPDATE: I just (May 22, 2013) downloaded Opera on my Samsung Galaxy S3 and it has the best HTML5 support so far. For my app, it continues to run javascript in the background, whether the screen is off, or Opera is pushed to the background, for at least a couple songs.