21

Is there a way to prevent a monitor from sleeping while on a web page?

I have a page with an animation in html that doesn't require user interaction. The monitor can sleep during this and I want to prevent this.

When watching a video on Hulu, I notice that the monitor doesn't sleep so there must be some way to prevent this.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
Tom Kincaid
  • 4,887
  • 6
  • 47
  • 72
  • As a quick thought -- would writing to HTML5 local storage be considered "doing something" by the web browser, and thus the monitor kept on? Unfortunately I'm not in a position to test this at the moment, but if that works out, you might be able to eliminate the need for Flash in addition to HTML5. – SeanKilleen Feb 21 '13 at 17:43
  • I tried running a script that set sessionStorage every 10 seconds, but the monitor still slept. There might be more to this to explore. – Tom Kincaid Feb 21 '13 at 21:17

2 Answers2

8

The talk about Flash got me wondering, so I made a simple move that just loops a short flv file. Lo and behold when on this page, the monitor doesn't sleep! So all I need to do is make a little movie that's just the background color of the page and loop that on pages where I don't want the monitor to sleep.

Tom Kincaid
  • 4,887
  • 6
  • 47
  • 72
  • Looks like the flv needs an audio track for this work even if the audio is silent. – Tom Kincaid Feb 21 '13 at 16:46
  • You mentioned you need a way to do it for a cross-platform web page. Is your intention of a 'simple movie that just loops a short flv file' cross-platform? Is there not a way in your HTML5 page/animation that you fake a mouse move? – Only You Feb 21 '13 at 18:08
  • Flash is on 99% of web browsers, so that's pretty good. If there is a way to do it with javascript that works for all html5 browsers, I'd take that. – Tom Kincaid Feb 21 '13 at 21:00
4

It's not possible in pure HTML. Hulu does it because it's Flash-based, and the plugin has access to the OS layers, which is something JS or HTML does not have. So the only way to do this would be to have a new paragraph in the HTML5 spec.

I suppose that the browser will disable sleep when going fullscreen, but it's to be verified.

See this post for more info.

CharlesB
  • 86,532
  • 28
  • 194
  • 218
  • OK, then how do I do it with a flash movie embedded on a web page? – Tom Kincaid Feb 21 '13 at 02:12
  • I believe it's handled by the flash plugin, it depends on which one is it, but I believe most of them do this. It would be a different question to ask here :) – CharlesB Feb 21 '13 at 07:51
  • Flash does not expose "the OS layers" any more than JS does *(in fact, Flash is more restrictive for many things, you need to delegate to JS for a lot of things)*. There's also no way to prevent the screen from going to sleep in Flash, as far as I can tell. – BlueRaja - Danny Pflughoeft Mar 28 '14 at 19:38