Can javascript detect if the android browser is in the foreground or in the background?

I have this HTML.

<html><body>
<a href="http://mydomain.com/video.mp4">PLAY ME!!!!!</a>
</body></html>
So, if someone clicks on the link, it loads its own media player, and the browser goes into the background, and when the video ends, it comes to the fore with the same page. Is there a way to detect this, that is, the browser, go into the background, and then go to the forefront in javascript?
+3
source share
3 answers

, , @ndtreviv linked , " ". Android. , , , WebView . , Android JavaScript.

0

webapps , , "", . : http://www.w3.org/TR/2013/REC-page-visibility-20131029/#sec-visibilitychange-event

, , . :

window.document.addEventListener("visibilitychange", function(e) {
  window.console.log('VISIBILITY CHANGE', window.document.visibilityState);
});
0

Android Chrome visibilitychange ; : http://output.jsbin.com/rinece

:

AOSP ( WebView Android < 4.4) , Chrome...

The visibilityChange event is now well supported on the mobile device - see http://caniuse.com/#search=visibility , but be careful that it is not supported by iOS UIWebView (even if it is enabled by iOS9).

0
source

Source: https://habr.com/ru/post/1773571/


All Articles