How to send signal `START_RECORDING` using html + ...
# ask-ai
r
How to send signal
START_RECORDING
using html + avascipt custom recording template
t
Thanks for reaching out, Bil. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I'm glad you're interested in sending the
START_RECORDING
signal using HTML and JavaScript with a custom recording template in LiveKit! Let me walk you through the steps to make this process smooth and clear: 1. First, use the Egress Template SDK by importing
EgressHelper
from
<EGRESS_SDK_URL>
. Just make sure to replace
<EGRESS_SDK_URL>
with the correct URL for the LiveKit Egress SDK. 2. Next, connect to the room using the
Room
object from the
livekit-client
SDK. 3. Once you’re connected and everything is ready, call
EgressHelper.startRecording()
. This will log
"START_RECORDING"
to the console, which triggers the recording process. 4. Finally, host your custom HTML/JS application and provide its URL as the
custom_base_url
when you start egress via the API. Here’s an example implementation to help you visualize it:
Copy code
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8"/>
  <title>Custom Recording Template</title>
</head>
<body>
  <div id="room"></div>

  <script type="module">
    import EgressHelper from '<EGRESS_SDK_URL>';
    import { Room } from 'livekit-client';

    const room = new Room();

    room.on('connected', () => {
      console.log('Connected to room:', room.name);
      EgressHelper.startRecording();
    });

    const url = EgressHelper.getLiveKitURL();
    const token = EgressHelper.getAccessToken();

    EgressHelper.setRoom(room);
    await room.connect(url, token);
  </script>
</body>
</html>
When you start egress via the API, just set the
custom_base_url
parameter to the URL where your custom template is hosted. The egress system will open your custom page, wait for the
START_RECORDING
log, and then begin recording. And if you want to test everything out beforehand, you can use the
lk egress test-template
CLI command to simulate the environment. It’s a handy way to make sure things are working as expected! Sources: Custom recording templates | LiveKit docs | template-default/index.html | README.md