vMix Forums
»
General
»
3rd Party Software and Development
»
simple scripting - countdown colour change clock for events
Rank: Member
Groups: Registered
Joined: 5/3/2015(UTC) Posts: 10 Location: UK
Was thanked: 6 time(s) in 3 post(s)
|
Here is a very simple script that will work with a countdown timer made in GT designer - dropbox link attached.
as it gets closer to the end of the countdown it goes from green (plus 5 mins) to yellow (5 - 2 mins) to red (0 - 2 mins) and flashes red/white once it runs out of time.
It uses the countdownclock.gtzip which is just a simple countdown timer.
Its been working on multiple events and keeping speakers to time as best as possible, as we send it back on a reverse feed on all the vimxcallers.
As far as I can tell It does not handle time that crosses midnight - as most of the events I do are across the day its not been an issue.
Hope someone finds it useful or as a bit of a jump start into scripting in vmix, as there is not much to go on sometimes.
Enjoy.
https://www.dropbox.com/s/ktsanzngb5cotsi/countdownclock.gtzip?dl=0
here's is the script for vmix scripting.
dim i As Integer dim time1 as String dim hourset as String dim minset as String dim secset as String dim Timemake as string dim date1 as DateTime dim remainingtime as TimeSpan dim rightnow as dateTime dim flashx as Boolean dim tClose as Integer dim tAlmost as Integer
' set parameters flashx = false i = 1 tClose = (5*60) ' set to 5 mins - is number of seconds tAlmost = (2*60) ' set to 2 mins - - is number of seconds
Do Until i = 2
' if you don't have countdownclock.gtzip and a field called Countdown.Text it won't do much dim content as string = Input.Find("countdownclock.gtzip").Text("CountDown.Text") 'Console.WriteLine(content) 'Console.WriteLine(content.Substring(3,2)) 'Console.WriteLine(content.Substring(6,2)) 'Console.WriteLine(content.Substring(9,2)) 'Console.WriteLine(System.DateTime.Now.ToLongTimeString + " " + content) rightnow = DateTime.Now hourset = content.Substring(3,2) minset = content.Substring(6,2) secset = content.Substring(9,2)
Timemake = hourset & ":" & minset &":" & secset 'Console.WriteLine(Timemake) Try date1 = Convert.ToDateTime(Timemake) Catch ex As System.Exception ' nothing End Try remainingtime = date1.Subtract(rightnow) console.Writeline("Time Left -" +remainingtime.TotalSeconds.Tostring)
If remainingtime.TotalSeconds > tClose then API.Function("SetTextColour",Input:="countdownclock.gtzip",Value:="40,200,40") Else if remainingtime.TotalSeconds < tAlmost then API.Function("SetTextColour",Input:="countdownclock.gtzip",Value:="255,40,40") Else API.Function("SetTextColour",Input:="countdownclock.gtzip",Value:="Yellow") End if
' Flash when out of time. if remainingtime.TotalSeconds < 1 then if flashx = true then API.Function("SetTextColour",Input:="countdownclock.gtzip",Value:="255,255,255") flashx = false Else API.Function("SetTextColour",Input:="countdownclock.gtzip",Value:="255,40,40") flashx = true End if End if
Sleep (300)
Loop
|
 4 users thanked alexbyrd for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 2/9/2021(UTC) Posts: 18  Location: Oklahoma Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
That is fantastic! Could you point me in the direction of modifying this to work with a countdown timer instead of a countdown clock?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 3/25/2020(UTC) Posts: 48  Location: Chichester Was thanked: 10 time(s) in 7 post(s)
|
Hi JessShake I modified the great work done by Alexbyrd script idea for those who want to use on the VMIX GT Timers, so have rewritten to work on the input you set the VMIX GT Timer on and use the API to compare the countdown time checks.
Also as defined below have set variables so you can change several settings
Variables InputNo = The Input the GT Timer is on countdowncolor = The default colour of the countdown
wrapuptime = Presenters first warning for color change i.e 5 minutes = 500 wrapuptimecolor = Colour change for Presenters first warning i.e YELLOW
finalcall = Presenters Second warning for color change i.e 2 minutes = 200 finalcallcolor = Colour change for Presenters second warning i.e RED
flashcolor = When reach 00:00:00 the colour to flash with finalcallcolor
Countdown time checks are calculated by taking the time string and converting to Integer to compare i.e string "00:05:00" = 5 minutes left = 500. so for example the wrapuptime variable is 500 The countdown value will always be lower than the check values in this format.
'************************************************************************************ '** Color Changing Countdown timer for standard VMIX GT timer - TimerCentre.gtzip ** '** '** Set variables for your required colour change times '**
'** InputNo = The input the time is setup on i.e input = 4 Dim InputNo as Integer = 24 '** Set the Countdown timer color when started. dim countdowncolor AS String = "Orange"
'** wrapuptime = The first time color change to warn time nearly up '** Countdown Time HH:MM:SS is converted to an integer. 01:10:00 = 11000 '** so 5 minute wrapup is 00:05:00 = 500. dim wrapuptime as Integer = 500 dim wrapuptimecolor AS String = "Yellow"
'** finalcall = The second time colour change to warn end of presenting '** Countdown Time HH:MM:SS is converted to an integer. 01:10:00 = 11000 '** so 2 minute finalcall is 00:02:00 = 200. dim finalcall as Integer = 200 dim finalcallcolor AS String = "Red"
'** Set the flash colour with the finalcallcolor when countdown 00:00:00 dim flashcolor AS String = "Black"
'** set parameters dim flashtimer as Boolean dim x as new system.xml.xmldocument Dim HHMMSS As String() dim i as integer dim timevar AS String flashtimer = false i = 1
Do Until i = 2
x.loadxml(API.XML())
'Fetch the current countdown time ************************************ dim xmlct As string = x.SelectSingleNode("//input[" & InputNo & "]/text[1]/text()").value
'** Create a time string HHMMSS *************************************** HHMMSS = xmlct.Split(New Char() {":"c}) timevar = HHMMSS(0) & HHMMSS(1) & HHMMSS(2)
' Convert Time String HHMMSS into a integer i.e 00:05:00 = 500 ******* dim timevarint as integer = Convert.toInt32(timevar)
'** Check if countdowntimer reached wraptuptime and finalcall ********** If timevarint > wrapuptime then API.Function("SetTextColour",Input:=InputNo,Value:=countdowncolor) Else if timevarint < finalcall then API.Function("SetTextColour",Input:=InputNo,Value:=finalcallcolor) Else API.Function("SetTextColour",Input:=InputNo,Value:=wrapuptimecolor) End if
' Flash timer when out of time timevarint is 00:00:00 = 0 if timevarint < 1 then if flashtimer = true then API.Function("SetTextColour",Input:=InputNo,Value:=flashcolor) flashtimer = false Else API.Function("SetTextColour",Input:=InputNo,Value:=finalcallcolor) flashtimer = true End if End if
Sleep (1000) Loop
|
 4 users thanked Aecast for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 2/9/2021(UTC) Posts: 18  Location: Oklahoma Thanks: 2 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you Aecast! This looks amazing. Exactly what I need!
-Jess
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/5/2021(UTC) Posts: 4  Location: Paris Thanks: 2 times
|
Hello Guys, thank you for this very usefull script!
May i ask few questions, i'm a script beginer ?
Aecast, your script only works for countdown with HH:mm:ss display format. Would it be possible to adapt the script for a MM:SS countdown?
Another question, is there an option in Vmix to continue the countdown after expiration? I didnt find it.
Thank you for your help!
Regards.
Aurélien
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/5/2021(UTC) Posts: 4  Location: Paris Thanks: 2 times
|
Of course, i can crop my countdown, but i wonder if there is a proper way to do that ;)
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,435  Location: Belgium Thanks: 309 times Was thanked: 999 time(s) in 827 post(s)
|
Originally Posted by: APX  Aecast, your script only works for countdown with HH:mm:ss display format. Would it be possible to adapt the script for a MM:SS countdown?
If the countdown display is set to mm:ss then just remove the '& HHMMSS(2)' from the 'timevar = HHMMSS(0) & HHMMSS(1) & HHMMSS(2)' line
|
 1 user thanked doggy for this useful post.
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,435  Location: Belgium Thanks: 309 times Was thanked: 999 time(s) in 827 post(s)
|
Originally Posted by: APX  Another question, is there an option in Vmix to continue the countdown after expiration? I didnt find it.
It's a countdown and stops when reaching the set time ;-) setup a second countdown (set to reverse) and trigger it to start with the OnCountdownCompleted of the first
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/5/2021(UTC) Posts: 4  Location: Paris Thanks: 2 times
|
Yes, Thank you, that is what i did.
I'll Try to learn how to do everything with one script!
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/5/2021(UTC) Posts: 4  Location: Paris Thanks: 2 times
|
Originally Posted by: doggy  Originally Posted by: APX  Aecast, your script only works for countdown with HH:mm:ss display format. Would it be possible to adapt the script for a MM:SS countdown?
If the countdown display is set to mm:ss then just remove the '& HHMMSS(2)' from the 'timevar = HHMMSS(0) & HHMMSS(1) & HHMMSS(2)' line Thank you that is exactly what i was trying to do_
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 2/19/2020(UTC) Posts: 1  Location: Lonon
|
Will or is there a way to get this to work for a count up timer??
Thanks. Jon
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/11/2021(UTC) Posts: 1
Thanks: 1 times
|
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,435  Location: Belgium Thanks: 309 times Was thanked: 999 time(s) in 827 post(s)
|
Originally Posted by: xiangyabing  学习了,谢谢分享 Oh yeah that's the answer LOL
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,435  Location: Belgium Thanks: 309 times Was thanked: 999 time(s) in 827 post(s)
|
Originally Posted by: psysjde1  Will or is there a way to get this to work for a count up timer??
Thanks. Jon Sure, use reverse logic
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/20/2022(UTC) Posts: 3  Location: Helsinki Thanks: 1 times
|
Hi,
And thanks for the script it is awesome!
But.. Is there an easy way to use input name instead of input number?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,435  Location: Belgium Thanks: 309 times Was thanked: 999 time(s) in 827 post(s)
|
Originally Posted by: akselio  Hi,
And thanks for the script it is awesome!
But.. Is there an easy way to use input name instead of input number? Sure use the input name instead of the number (string instead of an integer)
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/20/2022(UTC) Posts: 3  Location: Helsinki Thanks: 1 times
|
When i change input number to input name i get error on LINE 41: Object reference not set to an instance of an object.
ORIGINAL code in LINE 8 : Dim InputNo as Integer = 24
I Change it to LINE 8 : Dim InputNo as String = "COUNTDOWN"
And i get error on this LINE 41 dim xmlct As string = x.SelectSingleNode("//input[" & InputNo & "]/text[1]/text()").value
What i am doing wrong..again
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,435  Location: Belgium Thanks: 309 times Was thanked: 999 time(s) in 827 post(s)
|
Originally Posted by: akselio  When i change input number to input name i get error on LINE 41: Object reference not set to an instance of an object.
ORIGINAL code in LINE 8 : Dim InputNo as Integer = 24
I Change it to LINE 8 : Dim InputNo as String = "COUNTDOWN"
And i get error on this LINE 41 dim xmlct As string = x.SelectSingleNode("//input[" & InputNo & "]/text[1]/text()").value
What i am doing wrong..again Bad node selection code Honestly don't know why not have used the - Input.Find( - function instead of working on the xml. It's available and way clearer to understand if one is not familiar with scripting and especialy XML Xpaths Code:dim xmlct As string = x.SelectSingleNode("//input[@title='" & InputNo & "']/text[1]/text()").value
'and
dim xmlct As string = Input.Find(InputNo).Text("Time.Text") 'see helpfiles
'gets you the same result (Be sure the have the input name correct and in full )
'Your choise :-)
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 1/20/2022(UTC) Posts: 3  Location: Helsinki Thanks: 1 times
|
Thanks! Now it´s working like charm!
|
|
|
|
Rank: Member
Groups: Registered
Joined: 5/21/2015(UTC) Posts: 16 Location: Houston
Was thanked: 1 time(s) in 1 post(s)
|
Hi, this is great and thanks everyone for sharing. I was just curious to know if there was an easy string that could replace the flashing ending time and actually cause the timer to start counting up (reverse) after it reaches 0:00 in red color. This would indicate how long the speaker has gone over their time and would be super useful. Usually, I send a single counter input (with this script) to the monitor, so creating a second timer with a trigger on another input isn't possible for my use case.
|
|
|
|
vMix Forums
»
General
»
3rd Party Software and Development
»
simple scripting - countdown colour change clock for events
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close