User Tools

Site Tools


countdown_timer_in_vmix

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
countdown_timer_in_vmix [2023/10/22 14:00] peteraelligcountdown_timer_in_vmix [2023/10/27 08:48] (current) peteraellig
Line 1: Line 1:
 ===== CountDown Timer ===== ===== 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.+Attention: this timer works only from vMix version 27. Must have something to do with the NET version somehow.\\ 
 +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. If you change the countdown time, you have to change the script. 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.\\   * 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.\\
 {{::r1.jpg?600|}}\\ {{::r1.jpg?600|}}\\
   * 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.\\   * 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.\\
 {{::r2.jpg?600|}}\\ {{::r2.jpg?600|}}\\
-  * 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.\\+  * 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. The display gets the value from Dynamic Value1, this is a local variable of vMix. The value is set in the script when the countdown has been started once. So if you change the time in the script, it will be automatically set to the new value on shortcut reset.\\
 {{::r3.jpg?600|}}\\ {{::r3.jpg?600|}}\\
   * 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.\\   * 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.\\
Line 14: Line 15:
 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)\\ 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)\\
 {{::r6.jpg?600|}}\\ {{::r6.jpg?600|}}\\
 +
 +Adjust the variables described in the code, such as total time, warning times, their colors or the end text. Also you can use the variable overtimestop to influence whether the timer stops at the end with a message or the countdown starts counting up the overtime.\\
 +Lines with a ' sign at the beginning, are comments\\
 +
 +
 <code> <code>
 'Please change only the title name and the text field in the quotes.  'Please change only the title name and the text field in the quotes. 
Line 27: Line 33:
 'Please change only the numbers or the colors in the quotes! 'Please change only the numbers or the colors in the quotes!
 'Timer length in minutes and seconds 'Timer length in minutes and seconds
-Dim timerLengthMinutes As Integer = 1 +Dim timerLengthMinutes As Integer = 20 
-Dim timerLengthSeconds As Integer = 00+Dim timerLengthSeconds As Integer = 30
  
 'Warning time 1 in minutes and seconds 'Warning time 1 in minutes and seconds
Line 62: Line 68:
 Dim currentTime As DateTime Dim currentTime As DateTime
 API.Function("SetColor",Input:= title ,SelectedName:= "background.Fill.Color",Value:="#FF0000") API.Function("SetColor",Input:= title ,SelectedName:= "background.Fill.Color",Value:="#FF0000")
 +
 +'put countdowntime in a dynamic value for resetting the timer
 +API.Function("SetDynamicValue1", Value: timerLengthMinutes.tostring("00") + ":" + timerLengthSeconds.tostring("00"))  
 +
  
 Do Do
Line 91: Line 101:
 Dim timeLeft As TimeSpan = endTime - currentTime Dim timeLeft As TimeSpan = endTime - currentTime
 'option timedisplay in console 'option timedisplay in console
-Console.WriteLine("Remaining Time: " & timeLeft.ToString("mm\:ss"))+
 'time display in vMix 'time display in vMix
 +if  timeLeft.Tostring("hh") > "00" then
 +Console.WriteLine("Remaining Time: " & timeLeft.ToString("hh\:mm\:ss"))
 +API.Function("SetText",Input:= Title ,SelectedName:= Textfield ,Value:= timeLeft.ToString("hh\:mm\:ss"))
 +else
 +Console.WriteLine("Remaining Time: " & timeLeft.ToString("mm\:ss"))
 API.Function("SetText",Input:= Title ,SelectedName:= Textfield ,Value:= timeLeft.ToString("mm\:ss")) API.Function("SetText",Input:= Title ,SelectedName:= Textfield ,Value:= timeLeft.ToString("mm\:ss"))
 +end if
 +
 'waits 200 miliseconds 'waits 200 miliseconds
 sleep(200) sleep(200)
 Loop While True Loop While True
 </code>\\ </code>\\
-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.\\ +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 or the preset alone, which already contains the shortcuts and the script.\\ 
-DOWNLOAD +Loading with the Bundle option includes everything and also loads scripts and shortcuts.\\ 
 +[[https://drive.google.com/drive/folders/1RCPeVAT2pn6_bUIcyIraPslHpNzgtL6d?usp=sharing|download Title, Preset or Bundle]]\\ 
 +\\ 
 +DynamicValue also makes it easy to adjust the countdown times. With a streamdeck pad you could enter different times in Dynamicvalue and the script could then take the coutdown time from there.
  
countdown_timer_in_vmix.1697976039.txt.gz · Last modified: by peteraellig

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki