MADRIX Forum • Web API Call URL request
Page 1 of 1

Web API Call URL request

Posted: Mon Mar 28, 2016 10:24 pm
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

Re: Web API Call URL request

Posted: Tue Mar 29, 2016 11:41 am
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();
}


Re: Web API Call URL request

Posted: Tue Mar 29, 2016 6:02 pm
by SpencerIO
Thats great Guertler. Thank you.

Its nice to know that implementation is an option.

Regards,

SpencerIO