Web API Call URL request

Write here what nice effects or shows you have done with MADRIX or ask other users.

Moderator: MADRIX Team

Locked
SpencerIO
Posts: 2
Joined: Mon Mar 28, 2016 10:18 pm

Web API Call URL request

Post by SpencerIO »

Hello,

I would like to have a cue that plays different entries based on the current weather forecast.

To do this I would like to be able to make a Web API call to a URL and return a .json. based on the json data I would change the entry in the cue.

Is this possible? Otherwise I have to create an external application that would make the API call and control the MADRIX software with MIDI.

Sincerely,

SpencerIO
Guertler
Support
Support
Posts: 909
Joined: Tue Feb 04, 2014 10:47 am

Re: Web API Call URL request

Post by Guertler »

Hello SpencerIO,
Welcome to the MADRIX forum.
.
In MADRIX you have the possibility to use a so called "Main Output Macro" to read a textfile, evaluate it and change settings in MADRIX like to play another Cue in the "Cue List".
The script language is based on the programming language C. In the following link you will find an overview about the script:
http://help.madrix.com/m3/html/script/index.html
.
In your case you will need the script function "ReadAsync":
http://help.madrix.com/m3/html/script/i ... tions.html
With the help of the "ReadAsync" function you can read the file on the local PC and also on a webserver.
.
Also you will need a function which starts another cue in the Cue List when the weather was changed. Therefor you can use: CuelistGoto( int Value):
http://help.madrix.com/m3/html/script/i ... mples.html
.
Attached you will find a very simple code example how you can realize the switch of the Cues by changing the weather. You only need an application on the server which converts the .json file into a txt file.

Code: Select all

@scriptname="Change Cue of the Cue List by Weather";
@author="inoage GmbH";
@version="1.0";
@description="";

string txt;
string server ="http://www.testserver.de/testfile.txt";


void InitEffect()
{
	
}

void PreRenderEffect()
{

}

void PostRenderEffect()
{
	ReadAsync(server, txt);
	
	if(txt == "sun")
		CuelistGoto(0);
	
	if(txt == "cloudy")
		CuelistGoto(0);	
		
	if(txt == "rain")
		CuelistGoto(2);
		
	
}

void MatrixSizeChanged()
{
	InitEffect();
}

SpencerIO
Posts: 2
Joined: Mon Mar 28, 2016 10:18 pm

Re: Web API Call URL request

Post by SpencerIO »

Thats great Guertler. Thank you.

Its nice to know that implementation is an option.

Regards,

SpencerIO
Locked