renderVideo and renderAndWaitVideo take a template id and an options array.
The values to put into the template’s layers. A video layer takes a
src, and an audio track takes a src with its name. Modifications lists the fields each layer accepts.Render and wait for the URL
renderAndWaitVideo returns ['result' => $url] or ['error' => [...]].
Follow the progress
renderVideo returns a Generator of event arrays. The last event is done or error.
A refused request, such as an invalid API key or a used-up quota, gives one
error event. The client timeout applies only to the connection, because a video can wait in line for minutes.
Reconnect after a dropped connection
The video renders to its end, even when the connection drops. ThenrenderVideo reads the same video again by the id from the created event, and it continues to yield events. It never sends the render again, so you do not pay for a second video.
When the attempts run out, or the connection drops before the
created event, the last event is an error with the code TIMEOUT_ERROR. renderAndWaitVideo reconnects in the same way.
Start a video without waiting
createVideo starts the video and returns its id at once. It does not wait for the render. Then read the video with getVideo or watchVideo.
createVideo sends the render only once. A second request renders a second video.
Read a video again
Keep the id from thecreated event. getVideo returns the status of the video, and its URL when it is done.
status is queued, rendering, done, or failed. A failed video has an error string. An unknown id gives an error with the code NOT_FOUND.
watchVideo yields the events of the video again, from the latest one. It has no created event, and it reconnects as renderVideo does.