0

I met very strange problem - on Samsun Galaxy Note (and few other samsung devices), when I locking the screen (using lock screen button), video and sound from the webpage continue play in background...

I need to prevent it.

I made some debugging and realized that, when you press on the home button browser minimizing and tab is not active... but!!! when I press on the lock screen button - device lock the screen, but tab IS active in the browser, but orientation changed...

Also I tried to check, what kind of events fires, when you press on lock screen button... I used for that monitorEvents function and it shows, that only few events fires: devicemotion - which fires all time, deviceorientation - which fires on any moves with the device and resize - when phone changes the orientation...

At the moment I broke my brain looking for the solution... but I can't find anything related to the problem... Also I realized, that youtube handle this issue, on youtube it doesn't appears... but I have no idea how they did it...

Another things that I tried:

  • Visibility API doesn't handle this issue.
  • Events like focusout, blur not handling this issue.
  • Timers also not stoping their work, when screen is locked.

Any ideas or suggestions?

Dmytro Medvid
  • 4,988
  • 3
  • 25
  • 29

1 Answers1

0

It was mostly my fault, because I reloading video by timer if something goes wrong and it reloads in background when screen is locked.

So, the problem for Android Internet Browser. Version installed on my device is 2.1 which is Chromium based browser. Chromium version on this browser is 34. This kind of browser doesn't handle lock screen event on some set of devices, like Samsung Galaxy Note 3 [Android v5.0], Samsung Galaxy S7 [Android v6.0.1], Samsung Galaxy S5 [Android v5.0].

When I saying "browser doesn't handle lock screen event" - I mean that the browser can't recognize that device is locked now and page in browser still active...

There is few problems detected on this issue:

  • Visibility API doesn't handle this issue.
  • Events like window.focus, window.blur not handle this issue.
  • Timers also not stoping their work, when screen is locked.

I fixed my problem, because of only one thing - vide and audio tags from HTML5 triggers event pause when user clicks on lock screen button.

Dmytro Medvid
  • 4,988
  • 3
  • 25
  • 29