Rank: Advanced Member
Groups: Registered
Joined: 12/24/2021(UTC) Posts: 649  Location: athens Thanks: 155 times Was thanked: 84 time(s) in 80 post(s)
|
Hi. Im not script expert or programmer by any means. Im using AI to make more complex things. So i gave to AI your code and it respond with this version Code:
Do While True
' Πάρε το XML από το vMix
Dim xml As String = API.XML()
Sleep(100) ' λίγο χρόνο για να είναι "φρέσκο"
Dim x As New System.Xml.XmlDocument()
x.LoadXml(xml)
Dim previewInputNumber As String = x.SelectSingleNode("//preview").InnerText
Dim previewInputNode As XmlNode = x.SelectSingleNode("//input[@number='" & previewInputNumber & "']")
' Δηλώνουμε τα GUIDs
Dim Obs1 = "daae386f-674f-4743-b9db-5472f90225a4"
Dim Obs1Trim = "a615e862-44a5-48a5-9cb9-04d4af0e2c3c"
Dim Obs2 = "64ee059f-c6a6-4515-8d91-13b927ef3ef0"
Dim Obs2Trim = "654a3147-58ae-43de-a3c7-1fa1709d3304"
Dim Obs3 = "2f0f4e57-4773-40bc-bb7d-0159da84ec26"
Dim Obs3Trim = "cc87689c-2ec7-4033-9739-a0653d993758"
Dim Obs4 = "a3d713e0-59c7-42ec-b656-3863aec6d6b7"
Dim Obs4Trim = "fd0d07db-c472-4953-a276-31bfd59e6483"
Dim audioUp As String = ""
Dim overlayFound As Boolean = False
' Τσέκαρε τα overlay index 0 έως 2
For i As Integer = 0 To 2
Dim overlayNode As XmlNode = previewInputNode.SelectSingleNode("overlay[@index='" & i.ToString() & "']")
If overlayNode IsNot Nothing Then
audioUp = overlayNode.Attributes("key").Value
overlayFound = True
Exit For
End If
Next
If overlayFound Then
If audioUp = Obs1Trim Then
API.Function("AudioOn", Input:=Obs1)
API.Function("AudioOff", Input:=Obs2)
API.Function("AudioOff", Input:=Obs3)
API.Function("AudioOff", Input:=Obs4)
ElseIf audioUp = Obs2Trim Then
API.Function("AudioOn", Input:=Obs2)
API.Function("AudioOff", Input:=Obs1)
API.Function("AudioOff", Input:=Obs3)
API.Function("AudioOff", Input:=Obs4)
ElseIf audioUp = Obs3Trim Then
API.Function("AudioOn", Input:=Obs3)
API.Function("AudioOff", Input:=Obs1)
API.Function("AudioOff", Input:=Obs2)
API.Function("AudioOff", Input:=Obs4)
ElseIf audioUp = Obs4Trim Then
API.Function("AudioOn", Input:=Obs4)
API.Function("AudioOff", Input:=Obs1)
API.Function("AudioOff", Input:=Obs2)
API.Function("AudioOff", Input:=Obs3)
Else
' Αν υπάρχει overlay αλλά δεν είναι κάποιο από τα γνωστά
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Άγνωστο overlay στο preview")
End If
Else
' Αν δεν βρέθηκε overlay σε καμία layer
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Κανένα overlay στο preview")
End If
' Προαιρετικά: Μετάβαση
API.Function("Merge", Duration:=1000)
Sleep(1000) ' αναμονή 1 δευτερόλεπτο
Loop
And another one version that may help you Code:
Do While True
Dim xml As String = API.XML()
Dim doc As New System.Xml.XmlDocument()
doc.LoadXml(xml)
' Τα input keys που θέλεις να ελέγχεις
Dim inputKey1 As String = "ca353050-f012-4b9f-8e68-5519bd46e2b3"
Dim inputKey2 As String = "83f6b1c7-a937-425c-a67d-9a137b3dfbac"
' Ποιο input είναι το ενεργό (active)
Dim activeInputNumber As String = doc.SelectSingleNode("/vmix/active").InnerText
' Εντοπίζουμε τον κόμβο input που είναι ενεργός
Dim activeInputNode As XmlNode = doc.SelectSingleNode("/vmix/inputs/input[@number='" & activeInputNumber & "']")
If activeInputNode IsNot Nothing Then
Dim activeInputKey As String = activeInputNode.Attributes("key").Value
' Αν το ενεργό input είναι ένα από τα δύο που μας ενδιαφέρουν
If activeInputKey = inputKey1 Or activeInputKey = inputKey2 Then
Dim overlayNode As XmlNode = activeInputNode.SelectSingleNode("overlay[@index='0']")
If overlayNode IsNot Nothing Then
Dim overlayKey As String = overlayNode.Attributes("key").Value
Select Case overlayKey
Case "4f432bca-487a-48e1-bbf7-613196debff8"
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Audio In 1")
API.Function("AudioBusOn", Input:="OBS1", Value:="M")
API.Function("AudioBusOff", Input:="OBS2", Value:="M")
API.Function("AudioBusOff", Input:="OBS3", Value:="M")
API.Function("AudioBusOff", Input:="OBS4", Value:="M")
Case "4357ace2-0c1c-4c41-9562-e468fb1e32b2"
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Audio In 2")
API.Function("AudioBusOff", Input:="OBS1", Value:="M")
API.Function("AudioBusOn", Input:="OBS2", Value:="M")
API.Function("AudioBusOff", Input:="OBS3", Value:="M")
API.Function("AudioBusOff", Input:="OBS4", Value:="M")
Case "903d28fa-4b88-416f-9344-fc9807427428"
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Audio In 3")
API.Function("AudioBusOff", Input:="OBS1", Value:="M")
API.Function("AudioBusOff", Input:="OBS2", Value:="M")
API.Function("AudioBusOn", Input:="OBS3", Value:="M")
API.Function("AudioBusOff", Input:="OBS4", Value:="M")
Case Else
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Unknown overlay στο Layer 1")
End Select
Else
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Δεν βρέθηκε overlay index 0")
End If
Else
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Active input δεν είναι τα 2 που μας νοιάζουν")
End If
Else
API.Function("SetText", Input:="AUDIO STATUS", SelectedName:="Message.Text", Value:="Δεν βρέθηκε active input")
End If
Sleep(1000)
Loop
In the 2nd script here Dim inputKey1 As String = "ca353050-f012-4b9f-8e68-5519bd46e2b3" Dim inputKey2 As String = "83f6b1c7-a937-425c-a67d-9a137b3dfbac" we setup the first input key and the 2nd input key meaning the 2 "multiview windows" we use to merge and script checks what is on the first layer and if this input is active and it proceed further. Hope this helps
|