logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
TRMaCoy  
#1 Posted : Sunday, February 27, 2022 12:44:39 PM(UTC)
TRMaCoy

Rank: Member

Groups: Registered
Joined: 8/7/2020(UTC)
Posts: 14
United States
Location: Philadelphia

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
This is basic (I hope) but beyond the scope of my syntax understanding (which is built around 'swap pieces of text in and out until they work'.

Found this very handy script block on another post to administer remote commands to another vMix machine:

Dim client = WebRequest.Create("http://192.168.121.32:8088/api/?Function=AudioBusOn&Value=B&Input=Call_09")
Dim response = client.GetResponse()

Works great, and it's easy for me to figure out which vMix machine to point it at, and how to change the commands (that one sends Call_09 to Bus B on the machine at the .32 IP address, awesome).

How could I combine several of those commands into one script? So I want to send these commands to add Call_09 to bus B, and swap the vMix call sources to Output4/Audio Bus B:

Dim client = WebRequest.Create("http://192.168.121.32:8088/api/?Function=AudioBusOn&Value=B&Input=Call_09")
Dim response = client.GetResponse()
Dim client = WebRequest.Create("http://192.168.121.32:8088/api/?Function=VideoCallVideoSource&Value=Output4&Input=Call_09")
Dim response = client.GetResponse()
Dim client = WebRequest.Create("http://192.168.121.32:8088/api/?Function=VideoCallAudioSource&Value=BusB&Input=Call_09")
Dim response = client.GetResponse()

Obviously that block of text doesn't work or I wouldn't be here. Current error is Variable is defined without an As clause... but the single command doesn't need that. I've been fiddling for a while (different variable names, trying to get all the commands under one WebRequest) so I'm hoping someone can just fill me in on the painfully obvious thing I'm missing here as a result of just barely getting how Dim actually works in this syntax.
Thanks,
Tom
doggy  
#2 Posted : Sunday, February 27, 2022 4:27:57 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,082
Belgium
Location: Belgium

Thanks: 284 times
Was thanked: 920 time(s) in 759 post(s)
try

Code:
Dim client as WebRequest = WebRequest.Create("http://................
Dim response As WebResponse = client.GetResponse()
response.Close
TRMaCoy  
#3 Posted : Sunday, February 27, 2022 10:28:58 PM(UTC)
TRMaCoy

Rank: Member

Groups: Registered
Joined: 8/7/2020(UTC)
Posts: 14
United States
Location: Philadelphia

Thanks: 1 times
Was thanked: 1 time(s) in 1 post(s)
Much improvement. I had to make the additional client/response variables unique by numbering them, but this block now gives me no syntax errors. (Unsure if I need to also number the response.Close lines? Or are they just all purpose?)

Code:

Dim client as WebRequest = WebRequest.Create("http://192.168.111.32:8088/api/?Function=VideoCallVideoSource&Value=Output4&Input=Call_09")
Dim response as WebResponse = client.GetResponse()
response.Close
Dim client1 as WebRequest = WebRequest.Create("http://192.168.111:8088/api/?Function=VideoCallAudioSource&Input=Call_09&Value=BusB")
Dim response1 as WebResponse = client1.GetResponse()
response.Close
Dim client2 as WebRequest = WebRequest.Create("http://192.168.111:8088/api/?Function=AudioBusOn&Value=B&Input=Call_09")
Dim response2 as WebResponse = client2.GetResponse()
response.Close


And on testing it seems to do exactly what I need it to. Thanks!

One further tweak: I'd also like to add a single local command (Function=AudioBusOff&Value=A&Input=Call_09) to the script, but adding that in anywhere causes an Invalid Syntax on Line 1. I assume I can work around it with another WebRequest/Response block aimed at localhost or the local machines IP address, but in the interest of making it leaner, can that standard Function call exist in this script?
Best
doggy  
#4 Posted : Sunday, February 27, 2022 10:56:20 PM(UTC)
doggy

Rank: Advanced Member

Groups: Registered
Joined: 12/27/2012(UTC)
Posts: 5,082
Belgium
Location: Belgium

Thanks: 284 times
Was thanked: 920 time(s) in 759 post(s)
Originally Posted by: TRMaCoy Go to Quoted Post

One further tweak: I'd also like to add a single local command (Function=AudioBusOff&Value=A&Input=Call_09) to the script, but adding that in anywhere causes an Invalid Syntax on Line 1. I assume I can work around it with another WebRequest/Response block aimed at localhost or the local machines IP address, but in the interest of making it leaner, can that standard Function call exist in this script?
Best


Really need to read the helpfiles

Quote:
vMix Scripting supports the majority of VB.NET 2.0 code that will work within a single sub or function.
This means that custom classes and structures are not supported, however you can use the vast majority of the built in base classes in the .NET framework

including the handy System.Net.WebClient for downloading data over the internet.


Don't Mix different types of scripting

https://forums.vmix.com/posts/m70833-Scripting-for-Dummies#post70833
Users browsing this topic
Guest
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.