Start Broadcasting
After creating a room, obtain broadcasting credentials and connect to LiveKit to start streaming. This guide covers getting broadcaster data, connecting to LiveKit, and managing the broadcast session.Prerequisites
Before starting a broadcast, ensure you have:- Created a room - See Create Room for room creation
- Created a room post - Link the room to a post for social distribution
- Installed LiveKit SDK - Required for streaming connection
Getting Broadcaster Data
Retrieve the streaming credentials needed to connect to LiveKit. The broadcast data contains the connection URL and authentication token.Broadcast Data Types
| Type | Description | Properties |
|---|---|---|
CoHosts | Multi-host co-streaming session | coHostToken, coHostUrl |
Installing LiveKit SDK
Before connecting, install the LiveKit SDK for your platform:Connecting to LiveKit
Use thecoHostUrl as the WebSocket URL and the coHostToken as the access token to establish the streaming connection.
Complete Broadcasting Flow
Here’s the complete workflow from room creation to starting the broadcast:Stopping the Broadcast
To end the broadcast, disconnect from LiveKit and optionally stop the room:Connection Event Handling
Handle connection events for a robust streaming experience:Best Practices
Pre-Broadcast Setup
Pre-Broadcast Setup
- Test camera and microphone before going live
- Verify network connectivity and bandwidth
- Check permissions are granted on mobile devices
- Preview video before starting the broadcast
During Broadcast
During Broadcast
- Monitor connection quality indicators
- Handle reconnection events gracefully
- Provide visual feedback for connection states
- Keep the app in foreground for best performance
Ending Broadcast
Ending Broadcast
- Disconnect from LiveKit cleanly
- Call
stopRoom()to finalize the broadcast - Allow time for recording processing if enabled
- Notify viewers that the broadcast has ended
For detailed setup instructions, event handling, and advanced features, refer to the official LiveKit documentation.
Troubleshooting
Connection Failures
Connection Failures
Problem: Unable to connect to LiveKitSolutions:
- Verify
coHostTokenhasn’t expired - Check network connectivity
- Ensure camera/microphone permissions are granted
- Validate the
coHostUrlis correct
Track Publishing Issues
Track Publishing Issues
Problem: Camera or microphone not publishingSolutions:
- Check device permissions are granted
- Verify no other app is using the camera
- Try toggling tracks off and on again
- Restart the connection
Reconnection Loop
Reconnection Loop
Problem: Constantly reconnectingSolutions:
- Check network stability
- Monitor bandwidth availability
- Consider reducing video quality
- Check for background app restrictions