CountDown Timer

There are countless ways to implement a countdown timer in vMix. But if you want a timer that changes color at certain times, displays an end text or counts up the overtime at 0, then here is a solution suggestion. Apart from vMix, nothing else is needed. In the end, the solution consists of 2 keyboard shortcuts and a script. The script generates its own timer. The variables in the script can be adjusted relatively easily. Since the script starts counting down immediately after starting, it needs another keyboard shortcut that resets the initial display. So if you change the countdown time, you have to change the script and the reset keyboard shortcut. In the following I try to describe this process.

1. Create a keyboard shortcut, e.g. with the letter “R” (for reset), to stop the script Countdown (just in case it is still running) Set the Local Script checkbox to true.

2. Create an second keyboard shortcut, with the same letter as in point 1 (“R”), to which you assign the Setcolor function, as described in the picture below. This serves to reset the background, if it still shows the color for overtime, to black. Set the Local Script checkbox to true.

3. In the third shortcut, again with the same letter as the previous two shortcuts (“R”), this shortcut sets the text display to the start time of the countdown. e.g. 1 minute, as shown in the sample image below. Set the Local Script checkbox to true.

4. Create a fourth shortcut, e.g. with the letter “S” (for start) , assign the function ScriptStart to the shortcut, as shown in the picture below. Pay attention to correct upper-lower case Set the Local Script checkbox to true.

At the end it should look in your shortcut list, like in the picture below, together with possibly already existing shortcuts! Set the Local Script checkbox to true.

Then go to the Settings of vMix to the Scripting section. There you create a new script with Add and name it Countdown. Pay attention to correct upper-lower case. Set the Local Script checkbox to true. In the Script Text zone copy the following code and confirm with Save. (see picture and code below)

'Please change only the title name and the text field in the quotes.
'Upper or lower case is effective!!
'GT Tile name
'Write the title name exactly as you read it above the input window
Dim Title as string = "countdown.gtzip"
'Write the text field name exactly as you see it when you right-click in the title's input window
Dim Textfield as string = "time.Text"
'Please change only the numbers or the colors in the quotes!
'Timer length in minutes and seconds
Dim timerLengthMinutes As Integer = 1
Dim timerLengthSeconds As Integer = 00
'Warning time 1 in minutes and seconds
Dim warnTime1Minutes As Integer = 0
Dim warnTime1Seconds As Integer = 45
'Warning time 2 in minutes and seconds
Dim warnTime2Minutes As Integer = 0
Dim warnTime2Seconds As Integer = 10
'Colors
Dim startColor As String = "white"
Dim warnColor1 As String = "yellow"
Dim warnColor2 As String = "red"
'does the timer stop at finishing time or does the timer continue to count up overtime
'set the value to true, if you want to show the endtext and stop the clock and script
'set the value to false, if you want the counter to start counting up the timer
'Please change only the value to true or false!
dim overtimestop as boolean = false
'Text when the timer has expired at the end
Dim endText As String = "Time is over"
'----------------please do not make any changes from here on----------------------
'----------------unless you know what you are doing-------------------------------
Dim startTime As DateTime = DateTime.Now
Dim endTime As DateTime = startTime.AddMinutes(timerLengthMinutes).AddSeconds(timerLengthSeconds)
Dim warnTime1 As DateTime = endTime.AddMinutes(-warnTime1Minutes).AddSeconds(-warnTime1Seconds)
Dim warnTime2 As DateTime = endTime.AddMinutes(-warnTime2Minutes).AddSeconds(-warnTime2Seconds)
Dim currentTime As DateTime
API.Function("SetColor",Input:= title ,SelectedName:= "background.Fill.Color",Value:="#FF0000")
Do
currentTime = DateTime.Now
If currentTime >= endTime Then
'Startcolor and endtext
if overtimestop = true then
API.Function("SetText",Input:=Title,SelectedName:=Textfield, Value:= endText )
API.Function("SetTextColour",Input:=Title,SelectedName:= Textfield, Value:= startcolor)
Exit Do
else if overtimestop = false then
API.Function("SetColor",Input:= title ,SelectedName:= "background.Fill.Color",Value:="#FF0000")
API.Function("SetText",Input:=Title,SelectedName:=Textfield, Value:= endText )
API.Function("SetTextColour",Input:=Title,SelectedName:= Textfield, Value:= startcolor)
end if
ElseIf currentTime >= warnTime2 Then
'warning color 2
API.Function("SetTextColour",Input:=Title,SelectedName:= Textfield, Value:= warnColor2)
ElseIf currentTime >= warnTime1 Then
'warning color 1
API.Function("SetTextColour",Input:=Title,SelectedName:= Textfield, Value:= warnColor1)
Else
'standardcolor
API.Function("SetTextColour",Input:=Title,SelectedName:= Textfield, Value:= startcolor)
API.Function("SetColor",Input:= title ,SelectedName:= "background.Fill.Color",Value:="#000000")
End If
Dim timeLeft As TimeSpan = endTime - currentTime
'option timedisplay in console
Console.WriteLine("Remaining Time: " & timeLeft.ToString("mm\:ss"))
'time display in vMix
API.Function("SetText",Input:= Title ,SelectedName:= Textfield ,Value:= timeLeft.ToString("mm\:ss"))
'waits 200 miliseconds
sleep(200)
Loop While True

Finally, load the title into your vMix as used in the example. You can download the title here. I have also provided the whole thing as a bundle for download.
dowlnload Title, preset or bundle