Copy link to clipboard
Copied
Hi,
I have an interactive touchscreen with 7 screens. If the screen is idle for more than two minutes the screen reverts to the home/start screen.
This is the code on the home/start screen:
var root = this;
var delay = 120000;
var timeout = 0;
function main()
{
root.stop();
root.startButton.on("click", start);
anim_container.addEventListener("mousedown", wake);
anim_container.addEventListener("mousemove", wake);
}
function start(e)
{
root.gotoAndStop(1);
}
function wake(e)
{
clearTimeout(timeout);
timeout = setTimeout(idle, delay);
}
function idle()
{
root.gotoAndStop(0);
}
main();
-----------------------
I need to add a 4 min video to one of the frames, but the timeout kicks in at 2 minutes. I can increase the timeout but this isn't suitable. Is there any way to reset the delay time just for the video frame ?
Any help appreciated
Thanks
M
Copy link to clipboard
Copied
after two minutes (or whenever you want to reset your timer) use:
anim_container.dispatchEvent(new Event("mousemove"));
Copy link to clipboard
Copied
Many thanks for the response.
I'm relative new to javascript. In order to test, I have set the var delay value on homescreen to:
var delay = 5000;
And on the video frame I added:
this.stop();
anim_container.dispatchEvent(new Event("mousedown", wake1));
function wake1()
{
clearTimeout(timeout);
timeout = setTimeout(idle, 10000);
}
But when I click the link to the video from the homepage, which autoplays, it timesout after 5 seconds and not the expected 10 seconds.
I'm doing something wrong, but the question is where?
Copy link to clipboard
Copied
use the code i suggested
Copy link to clipboard
Copied
I've dropped in your line of code and can see if I move the mouse after the video plays it extends the timeout. I need to extend the time without having to move the mouse - so as soon as the frame/video loads and plays, prevent the timeout from returning the viewer to the homescreen, play the video to the end (4mins) and then automatically return to the homescreen. I'll have a play around with your code, if you think of a solution that would be super... Thanks
Copy link to clipboard
Copied
again, any (and every) time you want to reset your timeout, execute:
anim_container.dispatchEvent(new Event("mousemove"));
if you want to do that every minute so you never reset (eg, when video starts), use:
var mousemouseI = setInterval(function () {anim_container.dispatchEvent(new Event("mousemove"));}, 60000);
// when you no longer want that to occur (eg, video ends), use:
clearInteval(mousemoveI);