AMCP Commands Review
Here we review the AMCP commands used by CasparCG
Last updated
Was this helpful?
Here we review the AMCP commands used by CasparCG
Last updated
Was this helpful?
From the , "The Advanced Media Control Protocol (AMCP) is the main communication protocol used to control and query CasparCG Server." I would recommend saving that link, it will make getting back to the AMCP commands much easier in the future.
We are primarily interested in the . Let's break each of them down and explain how each of them can be used with our JavaScript file. If you are already familiar with the AMCP commands, you can skip to the .
CG ADD will load the HTML file from an URL or a file in the templates folder defined in your casparcg.config
file. Each HTML file loaded will be displayed on a device and occupy one layer. The channel and layer are defined as the first two properties in the CG ADD command.
The next parameter is the flash layer. This has no effect on our HTML template so we will always set it to 0
.
The next parameter is an URL or name of a HTML file in the templates folder. If you are using the HTTP-Server package setup in the section of this guide, then your command will look like the following.
To load a file from the CasparCG templates folder, remove the extension from the filename like so.
CasparCG version 2.1.1 NRK Build will only load files from the templates folder.
Next, we can add a Play On Load parameter that is either 0
or 1
. For now, we will set it to 0
.
CG UPDATE calls the JavaScript file's update
global function. It is also the only function that is passed a string of data. The CasparCG Server website says it is either string of JSON or XML data but, it can be any string. We will primarily be using JSON. We do need to escape the double quotes because CasparCG Server will not recognize single quotes as a string.
CG PLAY will call the JavaScript file's play
global function. It is designed to animate in the graphic.
CG NEXT will call the JavaScript file's next
global function. It is designed to advance the template to the next step. We will also be defining a non-standard function called previous
.
CG STOP will call the JavaScript file's stop
global function. It is designed to animate out the graphic.
CG REMOVE will call the JavaScript file's remove
global function. It is designed to prepare a graphic to be cleared. This can include things like saving local data, or making API calls.
CG INVOKE calls a custom function defined on the JavaScript file's global scope. In this guide, we will define the reset
and previous
functions to be invoked by the CasparCG server.
CG CLEAR will not interact with our JavaScript file at all. It will immediately clear the layer or channel provided. This will also remove our template if it is on that channel or layer.
Finally, we can add some optional data. We will define that in the within the JavaScript section of this guide.
on the CasparCG Wiki