Rank: Advanced Member
Groups: Registered
Joined: 11/23/2020(UTC) Posts: 170 Location: Wichita Thanks: 10 times Was thanked: 24 time(s) in 20 post(s)
|
Originally Posted by: knbPixels I believe currently that the time remaining being reported to Companion and available there as a variable is just a text string. Therefore we can't use it to do anything, we can only use it to display the TR on a button. But if the TR could be available to Companion in a way that can be interpreted as functional timecode of sorts, then we can use the time remaining to trigger actions in Companion.
Alternatively, I would love the trigger functions in vMix to be expanded to include not only "OnCountdownCompleted", But also "OnCountdownTime" and then the options for greater than, less than, and equals to a countdown timer reaching a specific mark. Use your OWN countdown in a script that can then do everything you need it to do at the appropriate time and in my case supports the countdown in a the one fashion not supported by the native countdown. Code:
'Countdown to Service start Script
' vMix Inputs - All will be referenced using their unique "key" (GUID) which will only change if the input is deleted and then added again, otherwise changing the name or input number will not affect this script
Dim WhichCountdownScreen() as string = {"17abeafe-9243-45a7-879d-94491046b873","b843684a-de64-4b1f-9fd9-bee3316c47c9"}
Dim CountdownScreen as string
Dim WhichCountdownTitle() as string = {"3e500d73-872c-4841-aa5c-67ebbf46d486","610f7530-72ff-4449-9180-cd4f9d0a4dc2"}
Dim CountdownTitle as string
Dim CountdownTitleText as string
Dim CountdownBackgroundMusic as string = "d34761a6-5c99-4bbd-acb8-6e4561d31eaf"
Dim AudioFeedFromSoundBoard as string = "57d87e62-8130-4b7a-a893-741d6c6c6472"
Dim SongCaptionsFromLaptop as string = "d257b307-e475-4aa9-abe6-6f03e9684d57"
Dim AnnouncementsFromLaptop as string = "5b5a4a6e-6f12-41ec-9bf0-0b5b29886be3"
Dim AnimatedLogo as string = "0f22c6b3-626f-40ef-910c-1b406ca55cd1"
Dim LiveOutput as string = "a961fbe3-55d7-40d9-bbd5-33922aa60a3f"
API.Function("ScriptStart","","BugOnBugOff") ' No key (GUID) for scripts in vMix
' Sunday Service begins in {0:10:00 AM|mm:ss}
Dim ServiceTime as string
Dim StreamingStartTime as string
Dim DayOfWeek as string = DateTime.Now.ToString("ddd")
Dim dtServiceTime as DateTime
Dim dtStreamingStartTime as DateTime
If DayOfWeek = "Sun" Then
CountdownScreen = WhichCountdownScreen(0)
CountdownTitle = WhichCountdownTitle(0)
CountdownTitleText = "Sunday Service begins in "
dtServiceTime = new DateTime(Datetime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ,10,00,00)
dtStreamingStartTime = new DateTime(Datetime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ,09,45,00)
End If
' ----------------- Testing time AT the moment
If DayOfWeek = "Sat" Then
CountdownScreen = WhichCountdownScreen(0)
CountdownTitle = WhichCountdownTitle(0)
CountdownTitleText = "Sunday Service begins in "
dtServiceTime = new DateTime(Datetime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ,15,33,00)
dtStreamingStartTime = new DateTime(Datetime.Now.Year, DateTime.Now.Month, DateTime.Now.Day ,15,30,00)
End If
If DayOfWeek = "Wed" Then
CountdownScreen = WhichCountdownScreen(1)
CountdownTitle = WhichCountdownTitle(1)
CountdownTitleText = "Wednesday night Bible Study begins in "
dtServiceTime = new DateTime(Datetime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 18,30,00) ' yyyy,mm,dd,hh,mm,ss - 24 hour time
dtStreamingStartTime = new DateTime(Datetime.Now.Year,DateTime.Now.Month, DateTime.Now.Day, 18,20,00)
End If
StreamingStartTime = dtStreamingStartTime.ToString("hh:mm")
ServiceTime = dtServiceTime.ToString("hh:mm")
console.writeline ( "ServiceTime=" & ServiceTime & " Stream starting time=" & StreamingStartTime & " Current time=" & DateTime.Now.ToString("hh:mm"))
API.Function("Restart",CountdownBackgroundMusic)
API.Function("Play",CountdownBackgroundMusic)
API.Function("CutDirect",CountdownScreen)
API.Function("AudioOff",AudioFeedFromSoundBoard)
API.Function("AudioOn",CountdownBackgroundMusic)
API.Function("ActiveInput",Mix:=3,Input:=CountdownScreen)
API.Function("OverlayInput3Off") ' Make sure that we don't have the Slideshow coming up in the "Song lyrics" overlay zone
' Main timer Loop
'
' We check for everything that needs to happen during the countdown in this loop:
' 1. End of the countdown
' 2. Time to start streaming (15 mins before end of countdown as of this comment being written)
'
Do While True
If ServiceTime = DateTime.Now.ToString("hh:mm") Then
' The times match so exit the loop!
Exit do
End If
If StreamingStartTime = DateTime.Now.ToString("hh:mm") Then
' Time to start the streaming
API.Function("StartStreaming","0")
End If
' Here we will update the countdown time in the "HeadlineText" of the countdown screen
Dim tsHowLong as TimeSpan = dtServiceTime - DateTime.Now
Dim stHowLong as String = tsHowLong.ToString.Substring(0,8)
If stHowLong.Substring(0,2) = "00" Then
stHowLong = stHowLong.Substring(3,5)
End If
API.Function("SetText",Input:=CountdownTitle,SelectedName:="Headline.Text",Value:= CountdownTitleText & stHowLong)
'console.writeline("Time Left = " & TimeLeft & " Hours left " & Hoursleft & " Minutes left " & CStr(MinutesLeft) & " Seconds left " & Secondsleft)
sleep(1000) ' Sleep for one second
Loop
Console.writeline("Starting service")
API.Function("AudioOff",CountdownBackgroundMusic)
API.Function("Pause",CountdownBackgroundMusic)
API.Function("AudioOn",AudioFeedFromSoundBoard)
API.Function("StartRecording")
API.Function("ActiveInput",Mix:=3,Input:=AnnouncementsFromLaptop)
API.Function("CutDirect",AnimatedLogo)
' Because I often forget to turn it on we'll wait one minute while Powerpoint is exited and ProPresenter is turned on then display the song subtitles
' of course that assumes someone remembers to get the Laptop ready for the song service --- but we only do this on Sunday, not Wednesday
If DayOfWeek = "Sun" Then
sleep(60000) ' Wait one Minute
API.Function("OverlayInput3In",SongCaptionsFromLaptop) ' Don't use the toggle API option, use the IN option just in case it IS remembered to turn it on. We don't want to turn it off if it is on.
End If
This is a working example you can use to create your own custom countdown.
|