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)
|
A countdown to a specific time script: Code:
' Because this partial implementation of VBSCRIPT doesn't support basic programming features like Functions or Subs everything has to be top down inline code.
' I'm going to have to see if I can't use Visual Studio and the vMixAPI.DLL
'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"
' 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
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)
' Main timer Loop
'
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)
sleep(1000) ' Sleep for one second
Loop
API.Function("AudioOff",CountdownBackgroundMusic)
API.Function("Pause",CountdownBackgroundMusic)
API.Function("AudioOn",AudioFeedFromSoundBoard)
It's an edited down version of what I run for our services (removed things like auto playing out animated logo at the beginning). It should work for you with a little bit of tweaking to meet your needs.
|