Rank: Newbie
Groups: Registered
Joined: 5/18/2020(UTC) Posts: 6 Location: Maryland
|
XML assistance
I'm trying to access info from xml node(s) from input multiviewer overlays.
for example, I need to store the key, panX, panY, zoomX, zoomY from each of the overlays (if they exist) from active input (105) as shown in vmix XML dump below. Thanks to assistance from Doggy, I know how to test if the nodes exist.
using tools at XmlToolBox it appears to me that this line would retrieve the key for overlay 1 of active input
overlay_1_key = (x.SelectSingleNode("//input[@number='"& activeinput &"']/overlay[1]@key").value)
but on running the script I get a message that line above has an invalid token. I've also noticed that the XLM below is slightly different for overlay index=1 than the higher numbers.
Any assistance on proper syntax for both overlay 1 statement and higher ones would be appreciated.
Jim
==============================
</input> <input key="7203e2ca-10c2-41e7-b5c1-0e5790e05593" number="105" type="Image" title="+8 +1 +2" shortTitle="+8 +1 +2" state="Paused" position="0" duration="0" loop="False"> +8 +1 +2 <overlay index="1" key="4ca50cb0-3e0d-4006-b0a0-a29b40bd46a2"> <position panX="-0.5" panY="0.48" zoomX="0.45" zoomY="0.45"/> </overlay> <overlay index="2" key="0b9dc391-719d-421c-9ebf-44c8e204e9c1"> <position panX="0.5" panY="0.48" zoomX="0.45" zoomY="0.45"/> </overlay> <overlay index="3" key="4b4815ec-5997-46e9-a963-d7f6dba5aedf"> <position panY="-0.5" zoomX="0.45" zoomY="0.45"/> </overlay> <overlay index="4" key="2c187249-69a0-4121-8a01-8424dd79bcbc"> <position panX="1.7"/> </overlay> <overlay index="5" key="bcc738d5-ce49-4354-b922-49b3d80862dc"> <position panX="1.7"/> </overlay> <overlay index="6" key="a65e749d-2614-4b00-873d-c05030714281"> <position panX="1.7"/> </overlay>
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Again : Please put code in language quote so it's readable (Next to regular quote button) and post as separate topic preferred for easier searching by othersposting just one line of code makes it sometimes pretty hard to try to help (figuring out the relation within the script) XmlToolBox is a little tool that can help but is not always showing what vMix needs Blatently copying it's results wont work but might help , but better help is understanding (search Google) how xml's are structured . Same applies to copying scripts and adapting them try Code: (x.SelectSingleNode("//input[@number='"& activeinput &"']/overlay[1]/@key").value)
Quote:I've also noticed that the XLM below is slightly different for overlay index=1 than the higher numbers. Part of interacting with the vMix API xml is checking what is shown , how and when. In this case (most often happens) some tokens are just omitted instead of blank ones. Your script needs to cater for that just like your previous script you modified! A script is only as clever as you programmed it ;-)
|
|
|
|
Rank: Member
Groups: Registered
Joined: 1/23/2015(UTC) Posts: 13 Location: Italy
Thanks: 1 times Was thanked: 3 time(s) in 2 post(s)
|
Hi everyone, first of all, thanks to doggy for is help! for me indirect but important. I've make this script to help me to automate the publish of some popup of sponsors, in a live streaming. I'm not a programmer and I think this is my little Frankenstein, sum of pieces of other script and guide. As the same, this post. I'm not know well the english language but I hope it's understendable for you. The prerequisite for the script work are: -input 1 as photos for the sponsor image like PopUp -input 2 as text.xaml whit first row named "Message" (it's usefull the standard vMix title "TextHD").This last is necessary as variable to keep memory of produced popups When I use it, I produce also a some full screenn promotional spots. This stop obviously, with a trigger, the PopUp script and when the spot end, the trigger start anothertime the script with the memory of the previous produced and keep it going. On the script are present some editable variables like: -name of photos input -live time in seconds -waiting time in minutes -Overlay channel -where to store the logThe script also make a log file for report. I hope this are usefull for anyone! Have a good script, Giulio Code:''''''''''''''''''''''''''''''''
'PopUp automate by Giulliu@2021'
''''''''''''''''''''''''''''''''
dim a,b,l,w,o,p,s as integer
dim f as string
dim path as string
dim now as string
dim url as string = "http://127.0.0.1:8088/api"
dim readcnt as XmlReader = XmlReader.Create(url)
readcnt.ReadToFollowing("text")
p=readcnt.ReadElementContentAsInt()
readcnt.Close()
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'edit the lines below as you pourpose
f="PopUp_STR" 'name of photos input
l=5 'live time in seconds
w=1 'waiting time in minutes
o=2 'Overlay channel
path="d:\editing\PopUpLOG.txt" 'where to store the log
'''''''''''''''''''''''''''''''''''''''''''''''''''''''
'don't touch the lines below
a=l*1000
b=w*60000
s=2000
Do While TRUE
Console.WriteLine("")
Overlay.Find(o).In (f)
now=DateTime.Now.ToString("dd/MM/yy HH:mm:ss")
dim readpop as XmlReader = XmlReader.Create(url)
readpop.ReadToFollowing("input")
dim pop As String = readpop.ReadInnerXml()
dim textout as String=(now & " - " &pop & " on Overlay " & o & " for " & l & " seconds")
Console.WriteLine(textout)
readpop.Close()
Sleep(a)
p=p+1
Console.WriteLine(p & " PopUp out")
Overlay.Find(o).Out
Console.WriteLine("")
API.Function("SetText",Input:="2",SelectedName:="Message",Value:=(p).tostring)
dim file as System.IO.StreamWriter
file=My.Computer.FileSystem.OpenTextFileWriter(path, True)
file.WriteLine(p & " " & textout)
file.Close()
Sleep(s)
Console.WriteLine("Change PopUp")
API.Function("NextPicture",f)
Console.WriteLine("Waiting " & w & " minutes for next PopUp overlay")
Sleep(b-a-s)
Loop
|
2 users thanked giulliu for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 8/7/2020(UTC) Posts: 14 Location: Philadelphia Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Very new to scripting, been using some basic ones with good success. Now I'm looking to get slightly more complicated, but a couple days digging hasn't really gotten me anywhere, so I'm hoping if someone might be kind enough to show me a few lines performing a specific function, I'll be able to interpolate a lot more; I'm mainly tripped up on defining and calling variables, which is something I haven't touched in any coding syntax for... twenty years? Yikes.
I'd like to do a conditional script based on what the AudioInputSource of a particular vMix call (name it Call_01) is set to.
So when the script is called, If Call_01 is listening to Bus B, do this, this, and that. Else, If Call_01 is listening to Bus C, do something else. And if neither of those conditions are met, do something else entirely.
Could anyone show me the syntax involved? I assume I have to define the AudioBus of Call_01 as a variable, then use that in the conditional statements, but since the last programming language I touched I think was QBasic (again, 20 years ago) I'm lost looking at the various tangentially related examples I've been trying to reverse engineer. Gratitude.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: TRMaCoy So when the script is called, If Call_01 is listening to Bus B, do this, this, and that. Else, If Call_01 is listening to Bus C, do something else. And if neither of those conditions are met, do something else entirely.
First off, have a look at previous scripts and snippets posted in this thread or others for referencing Second , Google search for info regarding vb.net programming as this is what is used in vMix scripting You need to get the call busses first of your input by pulling them form the vMix API XML (http://127.0.0.1:8088/api) Again there are a few examples posted before Code:dim busses as string = ""
busses = (x.SelectSingleNode("//input[@title='Call_01']/@audiobusses").Value)
' or check on callAudioSource
you might have to split up first the result if multiple busses are specified for this call code an if then else (google) Code:If busses = "A"
'do this
Else if busses = "B"
'do that
else
'do something else
end if
|
|
|
|
Rank: Member
Groups: Registered
Joined: 8/7/2020(UTC) Posts: 14 Location: Philadelphia Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Thank you for that. I have been been studying other references and samples, but there's some underlying stuff that's not clicking yet. So the first code example is helpful.
When I try and run the first code above I get a BC30398 'x' is not accessible in this context because it is 'Private'. I assume this is something painfully obvious I'm missing, but not seeing it mentioned in searching other posts. Thanks.
|
|
|
|
Rank: Member
Groups: Registered
Joined: 8/7/2020(UTC) Posts: 14 Location: Philadelphia Thanks: 1 times Was thanked: 1 time(s) in 1 post(s)
|
Alright, figured that last bit out; didn't follow that the x in x.Select referred to a variable you have to previously define. Again, 20 years without any measure of coding. So this
dim xml = API.XML() dim x as new system.xml.xmldocument x.loadxml(xml)
is going to be needed anytime you're pulling data out of the local XML file? Just the first thing I grabbed from another sample that seemed to get things working.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Display clock for different timezone in titlemost basic Code:Dim d1 As DateTime = DateTime.Now.AddHours(3)
API.Function("SetText",Input:=45,SelectedIndex:="0" ,Value:=d1.ToString("dd/MM/yy H:mm:ss"))
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 11/20/2020(UTC) Posts: 74 Thanks: 13 times Was thanked: 9 time(s) in 9 post(s)
|
Hi Champs, go a bit deeper into scripting and have started to create a VB.net App for Vmix control and monitoring. My Question is there a better way to send multiple commands to a "slave machine"? Before these commands I read out the xml/api to bet the information which audio busses are active "ab2/3" and with these commands I send the information to a title generator to display them. Code:Dim ab1 as string = ""
Dim ab2 as string = ""
Dim ab3 as string = ""
Dim ab4 as string = ""
Dim ab5 as string = ""
Dim ab6 as string = ""
'Werte auslesen
do while true
Dim xml as string = API.XML()
Dim x as new system.xml.xmldocument
x.load("http://192.168.200.166:8088/api")
ab1 = (x.SelectSingleNode("//input[1]/@audiobusses").InnerText)
ab2 = (x.SelectSingleNode("//input[2]/@audiobusses").InnerText)
ab3 = (x.SelectSingleNode("//input[3]/@audiobusses").InnerText)
ab4 = (x.SelectSingleNode("//input[4]/@audiobusses").InnerText)
ab5 = (x.SelectSingleNode("//input[5]/@audiobusses").InnerText)
ab6 = (x.SelectSingleNode("//input[6]/@audiobusses").InnerText)
'Call 1 Darstellung Audio Bus
Dim client as Webrequest = WebRequest.Create("http://192.168.200.199:8088/api/?Function=SetText&Input=1&SelectedName=ABCall1.Text&Value="&ab1)
Dim response as Webresponse = client.GetResponse()
response.Close
'Call 2 Darstellung Audio Bus
Dim client2 as Webrequest = WebRequest.Create("http://192.168.200.199:8088/api/?Function=SetText&Input=1&SelectedName=ABCall2.Text&Value="&ab2)
Dim response2 as Webresponse = client2.GetResponse()
response2.Close
'Call 3 Darstellung Status
Dim client3 as Webrequest = WebRequest.Create("http://192.168.200.199:8088/api/?Function=SetText&Input=1&SelectedName=ABCall3.Text&Value="&ab3)
Dim response3 as Webresponse = client3.GetResponse()
response3.Close
'Call 4 Darstellung Status
Dim client4 as Webrequest = WebRequest.Create("http://192.168.200.199:8088/api/?Function=SetText&Input=1&SelectedName=ABCall4.Text&Value="&ab4)
Dim response4 as Webresponse = client4.GetResponse()
response4.Close
'Call 5 Darstellung Status
Dim client5 as Webrequest = WebRequest.Create("http://192.168.200.199:8088/api/?Function=SetText&Input=1&SelectedName=ABCall5.Text&Value="&ab5)
Dim response5 as Webresponse = client5.GetResponse()
response5.Close
'Call 6 Darstellung Status
Dim client6 as Webrequest = WebRequest.Create("http://192.168.200.199:8088/api/?Function=SetText&Input=1&SelectedName=ABCall6.Text&Value="&ab6)
Dim response6 as Webresponse = client6.GetResponse()
response6.Close
sleep (1000)
loop
this is still running on a Vmix machine , the plan is to transfer it into VB.net when completed and tested...
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 2/2/2017(UTC) Posts: 9 Location: Australia
Was thanked: 1 time(s) in 1 post(s)
|
Hey Brains Trust. I'm wanting to use a string variable to set the index I want to change in a multiview. tochange and overlay strings are working fine. But I can't get the syntax right to change the index value of "1" to a variable string. Any help appreciated Quote:API.Function("SetMultiViewOverlay" ,Input:=tochange ,Value:= "1," & overlay.tostring()) Cheers, JB
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/4/2020(UTC) Posts: 22 Was thanked: 1 time(s) in 1 post(s)
|
Can anyone please enlighten me? I want to adjust the sizing of an input through an API.Function call but I can't figure out the correct syntax. I want to adjust zoomX, zoomY, panX, and panY. Could someone point me in the right direction? Thanks.
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: Hallaman Hey Brains Trust. I'm wanting to use a string variable to set the index I want to change in a multiview. tochange and overlay strings are working fine. But I can't get the syntax right to change the index value of "1" to a variable string. Any help appreciated Quote:API.Function("SetMultiViewOverlay" ,Input:=tochange ,Value:= "1," & overlay.tostring()) Cheers, JB Is tochange defined as a string ? Is overlay defined as an integer ?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: BasilChessman Can anyone please enlighten me? I want to adjust the sizing of an input through an API.Function call but I can't figure out the correct syntax. I want to adjust zoomX, zoomY, panX, and panY. Could someone point me in the right direction? Thanks. have you checked the list of available shortcuts ? There are no zoomX and zoomY , just a setzoom Have you checked previous posts here , should be clear enough Code:API.Function("SetZoom",Input:="1",Value:="0.6295")
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 2/16/2017(UTC) Posts: 125 Thanks: 25 times Was thanked: 25 time(s) in 18 post(s)
|
Originally Posted by: BasilChessman Can anyone please enlighten me? I want to adjust the sizing of an input through an API.Function call but I can't figure out the correct syntax. I want to adjust zoomX, zoomY, panX, and panY. Could someone point me in the right direction? Thanks. You can use this: Code:http://127.0.0.1:8088/API/?Function=SetPanX&Value=0.224&Input=1
http://127.0.0.1:8088/API/?Function=SetPanX&Value=-0.206&Input=1
http://127.0.0.1:8088/API/?Function=SetZoom&Value=0.5&Input=1
There's no function for zoomX or zoomY, just for zoom
|
|
|
|
Rank: Member
Groups: Registered
Joined: 1/23/2015(UTC) Posts: 13 Location: Italy
Thanks: 1 times Was thanked: 3 time(s) in 2 post(s)
|
Hi to all, I made this project, after Massimiliano request/idea. It consist on one button cycling input, for Layer/Multiview, very simple and think very helpfull (thanks Massimiliano) Main parts are: -One Text input as settings of variables for the range of selectable input. -One Layer/Multiview Inpus as pourpose. -One script that check if LEFT and RIGHT are greater than Stop and set it to Start. Put on Layer/Multiview Input position 2 and 3, the LEFT and RIGHT value.
The prerequisite for the script work are: -input 1 as "text" input (like as in project and video).Have a good script, Giulio 2BOXcycling.rar (20kb) downloaded 16 time(s).Code:'''''''''''''''''''''''''''''''''''''''''
'2BOX One Button Cycling by Giulliu@2021'
'''''''''''''''''''''''''''''''''''''''''
dim mv as string
dim sta,sto,lf,rg as integer
'''''''''''''''''''''''''''''''''''''''''
'edit the lines below as you pourpose
mv = "2BOX" 'name of Layer/Multiview Input
'''''''''''''''''''''''''''''''''''''''''
Do While TRUE
dim url as string = "http://127.0.0.1:8088/api"
dim readcnt as XmlReader = XmlReader.Create(url)
readcnt.ReadToFollowing("text")
sta=readcnt.ReadElementContentAsInt()
sto=readcnt.ReadElementContentAsInt()
lf=readcnt.ReadElementContentAsInt()
rg=readcnt.ReadElementContentAsInt()
readcnt.Close()
If lf > sto Then
API.Function("SetText",Input:="1",SelectedName:="SelectedLEFT.Text",Value:=(sta).ToString)
End If
If rg > sto Then
API.Function("SetText",Input:="1",SelectedName:="SelectedRIGHT.Text",Value:=(sta).ToString)
End If
API.Function("SetMultiViewOverlay",mv,"2," & lf.ToString)
API.Function("SetMultiViewOverlay",mv,"3," & rg.ToString)
Sleep(100)
Loop
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/4/2020(UTC) Posts: 22 Was thanked: 1 time(s) in 1 post(s)
|
Originally Posted by: doggy have you checked the list of available shortcuts ? There are no zoomX and zoomY , just a setzoom Have you checked previous posts here , should be clear enough
Thank you. I did check the list of available shortcuts and found no mention of pan settings. I saw zoomX and zoomY in the API info for my inputs, but didn't see separate functions for those either. Now I know that those functions don't exist. I've gotten lots of great info from this thread. If this question has been covered previously, I must have overlooked it when searching for the answer. Thanks again for your help.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 4/9/2020(UTC) Posts: 7 Location: montréal Thanks: 4 times
|
I would like to know if it is possible to design a script which would detect the sources which are in layer (1 to 10) of an input and which could put their sound on.
trigger and shortcut is not an option because the sources of the layers change continuously during production
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: chasseb I would like to know if it is possible to design a script which would detect the sources which are in layer (1 to 10)
Yes is possible ( all the info can be pulled from the API XML for that )
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 4/9/2020(UTC) Posts: 7 Location: montréal Thanks: 4 times
|
thank you doggy,
how do i start if i'm new to doing scripting?
|
|
|
|
Rank: Advanced Member
Groups: Registered
Joined: 12/27/2012(UTC) Posts: 5,216 Location: Belgium Thanks: 291 times Was thanked: 955 time(s) in 790 post(s)
|
Originally Posted by: chasseb how do i start if i'm new to doing scripting? In vMix got to settings and select scripting Click on Add to create a new script enter the code and save and run the script by selecting the script and press start or call the script with a function this thread has many small example to play with (start at page 1) for the code that is not vMix specific like its functions one can google for how to program in vb.net to get an understanding of what some of the code in the examples does Code:Console.WriteLine("Hello World")
|
2 users thanked doggy for this useful post.
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close