Controle Programático de Webcam
No topo da API do Botão Personalizado você pode controlar programaticamente o gravador da webcam, ie., sem necessidade de interação do usuário. Você deve combinar o controle programático da webcam com o retorno de chamada
onWebcamStatusChange, que permitirá a você manter o estado do seu código em sincronia com o estado atual do gravador da webcam. A chamada
We recommand to initially call the
areRecordingDevicesReady() function, which resolves if the webcam can be successfully accessed and recording is generally possible. You can use this call as a “preflight” check to confirm that the subsequent calls can be performed. Please note that
areRecordingDevicesReady may require a user interaction to approve a browser popup that prompts the browser to approve the domain api.clipchamp.com to access the webcam and microphone. Once approved, the corresponding permission is typically stored in the browser profile, but may be revoked at any time as a result of the user clearing out the browser cache, using the browser’s incognito mode, new hardware devices becoming available or other incidents. Hence, it is a good idea to precede every invocation of the programmatic webcam control API by an
areRecordingDevicesReady() call. The other functions of the programmatic webcam control API are:
startRecording(): Starts the recording if the Clipchamp widget shows the webcam screen and the webcam capture is on.
pauseRecording(): Pauses the recording if a recording was previously started and is not currently paused.
resumeRecording(): Resumes the recording if a recording was previously started and is currently paused.
finishRecording(): Finishes the recording and triggers the subsequent processing of the video.
cancelRecording(): Aborts a recording and closes the Clipchamp widget.
All of these functions are asynchronous and may return before the corresponding action is complete. Please use the
onWebcamStatusChange callback to synchronize any state on your side with the actual state of the webcam recorder. If a function of the webcam control API is called and the webcam recorder is in an incompatible state, the call may not be queued for later execution when the webcam recorder has reached the correct state. For instance, the behavior of the webcam control API is not defined when you call
startRecording(), but the
onWebcamStatusChange callback has not previously signaled that the webcam capture was successfully switched on (