Controlling mimoLive with php

We have a good documented sample php script on github:
https://github.com/boinx/mimoLive-HTTP-Demo

Controlling mimoLive with CURL

To control mimoLive via HTTP you can use the bash command “curl”. For the curl commands to work you need to find the ID of your document you want to manipulate.

Controlling mimoLive with Automation layer

The Automation layer can perform some easy commands to trigger actions in mimLive by their API Endpoints. It also have an httpRequest() command to perform any kind of GET request actions the HTTP API is capable of.

Prerequisites

- Open the document you want to manipulate in mimoLive.
- Make sure the the document is in a finished state so that the API endpoints like Layers do not change anymore. Please be aware that if you remove a layer and add it again this layer will have a different Layer ID when talking to it via the API.
- Enable the HTTP-Server in mimoLive Remote Control Preferences. Check the “Allow Remote Control Access” option:

Getting an API Endpoint

Befor mimoLive 5.5 it was hard to get the Document ID and e.g. a Layer ID with Terminal commands looking through long JSON data. Since mimoLive 5.5 its much easier:

First of all copy the mimoLive HTTP server base URL from the Remote Control section of the mimoLive Preference window (see screenshot above). Open a text editor (e.g. TextEdit by Apple) and paste the Clipboard content into a newly created text document. Please make sure, that there is no backslash at the end of the URL! The result should look like this:

http://172.28.30.202:8989

In the mimoLive document window with your mouse you can right-cilck (or control-click, or two-finger-click) on the object of interest (e.g. a Layer, a Source, a button of a Layer control) to get a context menu. There is one menu item that let you copy the API Endpoint to the macOS Clipboard for using it in your mimoLive API project.

In the mimoLive document window with your mouse you can right-cilck (or control-click, or two-finger-click) on the object of interest (e.g. a Layer, a Source, a button of a Layer control) to get a context menu. There is one menu item that let you copy the API Endpoint to the macOS Clipboard for using it in your mimoLive API project.

Go back to your text editor and paste the just copied API Endpoint after the HTTP Server base URL. Now the URL in your text browser should look like this:

http://172.28.30.202:8989/api/v1/documents/458706932/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B

This is the final API Endpoint to address a layer in your document. In this example 458706932 is the document ID and BA868701-8131-49CB-8EDD-8C7E6E7CD60B is the specific layer ID of a certain layer in this document.

Switching ON and OFF a Layer

- With the retrieved API Endpoint for a certain layer you can toggle it on and off with the following terminal commands.

curl xxxxxxxxx/setLive
curl xxxxxxxxx/setOff
curl xxxxxxxxx/toggleLive
# our example will look like this:
curl http://172.28.30.202:8989/api/v1/documents/458706932/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B/setLive

Setting a Value of a Layer

- All the parameter of a layer can be set via the HTTP API. You need to find the correct key in order to set a new value. In our example we will set the Title of a Lower Third Layer with the key tvGroup_Content__Title. Because we need to send the new value in a JSON file to the HTTP server with a PUT request the curl command gets a bit crowded.

curl -d '{"input-values":{"tvGroup_Content__Title":"My new title"}}' -H "Content-Type: application/json" -X PUT "xxxxxxxxx"

Collection of Useful Curl Commands for you to explore

Setting the RTMP URL and Streaming key of a Live Streaming Output Destination:

curl --data '{"data": { "attributes": {"settings": {"rtmpurl":"rtmp://mystreaminghost.com", "streamingkey":"MYTOTALLYSECRETSTREAMKEY"} } } }' --request PATCH http://192.168.0.100:8989/api/v1/documents/458706932/output-destinations/4D072496-1CE3-418E-B73E-59A2927A2110

Setting the file name and path of a File Writer Output Destination

curl --data '{"data": { "attributes": {"settings": { "location": "~/Destktop/Recordings", "filename": "MyGreatShow %year-%month-%day-%hour-%minute.%extension" } } } }' --request PATCH http://192.168.0.100:8989/api/v1/documents/458706932/output-destinations/4D072496-1CE3-418E-B73E-59EDA388BB

Setting the video source of a Placer layer

yyyyyyyyyyyyy will be the UUID of the video source. (e.g CCAF4418-367A-415F-AD25-6536C3EF3512)

xxxxxxxxxxxxx will be the API endpoint of the certain layer variant. (e.g. http://172.28.30.202:8989/api/v1/documents/2014814935/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B/variants/AA868701-8131-49CB-8EDD-8C7E6E7CD60A)

curl -d '{"input-values":{"tvIn_VideoSourceAImage":"yyyyyyyyyyyyy"}}' -H "Content-Type: application/json" -X PUT "xxxxxxxxxxxxxxxx"

Setting the volume of a layer that has an audio volume knob

With this curl command you can change the audio volume of a layer that has an audio adjustment knob (like the Placer layer). The value “volume” can take values from 0.0 to 1.0.

xxxxxxxxxxxxx will be the API endpoint of the layer (e.g. http://10.101.2.2:8989/api/v1/documents/13195157/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B)

curl -d '{"volume": 0.5}' -H "Content-Type: application/json" -X PUT "xxxxxxxxxxxxxxxx"

Setting the color of a Background layer

xxxxxxxxxxxxx will be the API endpoint of the certain layer variant. (e.g. http://172.28.30.202:8989/api/v1/documents/2014814935/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B/variants/AA868701-8131-49CB-8EDD-8C7E6E7CD60A)

curl -d '{"input-values":{"tvGroup_Appearance__Color_1":{"red": 1.0, "blue": 0.5, "green": 0, "alpha": 0.5}}}' -H "Content-Type: application/json" -X PUT "xxxxxxxxxxxxxxxx"

Controlling mimoLive with Apple Script

Currently mimoLive doesn’t natively support Apple Script. However you can use a workaround to reach out to mimoLive: There is a “do shell script” command in apple script that let you perform bash commands like “curl”. The previous section explains how to create a curl command to manipulate a certain layer or layer value.

Once you are satisfied with your curl command you need to wrap it in a “do shell script” command in Apple Script:

This example shows how to set the title of a lower third:

set layerAPIEndpoint to "xxxxxxxxx" -- in our example this would be "http://172.28.30.202:8989/api/v1/documents/458706932/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B"
set lowerThirdTitle to "Hello World!"
do shell script "curl -d '{\"input-values\":{\"tvGroup_Content__Title\":\"" & lowerThirdTitle & "\"}}' -H \"Content-Type: application/json\" -X PUT \"" & layerAPIEndpoint & "\"" as text

The following example Apple script shows how to switch on a layer every half an hour on the hour: This is could be useful for commercial overlays. Make sure to use a layer that will switch it self off after a certain time (e.g. a Placer Layer with a non looping movie source will do so).

-- configure your Layer API Endpoint:
set layerAPIEndpoint to "xxxxxxxxx" -- in our example this would be "http://172.28.30.202:8989/api/v1/documents/458706932/layers/BA868701-8131-49CB-8EDD-8C7E6E7CD60B"
-- repeat endlessly:
repeat
	-- get the seconds last in this hour
	set currentDate to current date
	set secondsToNextHour to 3600 - ((minutes of currentDate) * 60 + (seconds of currentDate))
	-- --------------------------------------------
	-- The following code snippet is useful only if you want to
	-- switch the layer live on half hours also.
	-- if you don't want this behaviour you can delete this part.
	-- --------------------------------------------
	-- check if we are currently in the first half of the hour
	if secondsToNextHour > 1800 then
		-- yes, we are in the first half of the hour, so only wait half the time
		set secondsToNextHour to secondsToNextHour - 1800
	end if
	-- --------------------------------------------
	-- wait until the time to trigger the layer
	delay secondsToNextHour
	-- set the specified layer to live:
	do shell script "curl \"" & layerAPIEndpoint & "/setLive\"" as text
	-- wait a couple of seconds to make sure we don't glitch in time
	delay 5
end repeat

Feedback

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.

Post your comment on this topic.

Post Comment