Timer called function on expiry but not after
in Using jQuery Plugins
•
11 years ago
Timer Plugin
My goal is to have set up two youtube videos. VideoA now and VideoB Later. When the countdown finishes at 5pm I want the video to switch from A to B. Using the countdown timer I've gotten that to work. I set the timer for say 90 seconds after load and it swaps out perfectly fine. If I set the timer for 11pm tonight it will switch fine.
The problem is if I set the timer for 11pm tonight and I load the page at 11:30 the timer says 0:0:0 but it doesn't activate the switch function.
As per the documentation:
On expiry a callback is made to allow you to action the countdown. You can force this event to fire even if the countdown starts after the target time by setting alwaysExpire to true.
and:
Name - alwaysExpire
Type - boolean
Default - false
Comment - If true, the onExpiry event is triggered even when the counter starts after the target time. If false, the event only triggers if the counter actively times out.
My Current html looks like this - Pastebin Link - you'll note if you alter the expiry variable. If you set it to "+10s" it works fine. If you set it to 5 minute from now using new Date () it works. but if you check afterwards my change_video isn't working.
My end goal is a series of videos. Every day a new video. So until I learn how to set up an array what I'll do is let the timer do it's thing (because I want the switch to happen at a very specific time) and then in the evening I'll go in and bump up the variables (Now=VideoB Later=VideoC) and reset the timer for tomorrow. Logically it's simple enough even if it does require daily maintenance. It's just that I need to make sure the video switches if someone comes late.
2