Skip to content

Commit ce18c35

Browse files
authored
Create README (#2)
1 parent d4ae48d commit ce18c35

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
[![crates.io](https://img.shields.io/pypi/v/livekit.svg)](https://pypi.org/project/livekit/)
3+
4+
# client-sdk-python
5+
The Livekit Python Client provides a convenient interface for integrating Livekit's real-time video and audio capabilities into your Python applications. With this library, developers can easily leverage Livekit's WebRTC functionalities, allowing them to focus on building their AI models or other application logic without worrying about the complexities of WebRTC.
6+
7+
### Connecting to a room
8+
```python
9+
async def main():
10+
room = livekit.Room()
11+
await room.connect(URL, TOKEN)
12+
logging.info("connected to room %s", room.name)
13+
14+
@room.on("participant_connected")
15+
def on_participant_connected(participant: livekit.RemoteParticipant):
16+
logging.info(
17+
"participant connected: %s %s", participant.sid, participant.identity)
18+
19+
video_stream = None
20+
@room.on("track_subscribed")
21+
def on_track_subscribed(track: livekit.Track, publication: livekit.RemoteTrackPublication, participant: livekit.RemoteParticipant):
22+
logging.info("track subscribed: %s", publication.sid)
23+
if track.kind == livekit.TrackKind.KIND_VIDEO:
24+
nonlocal video_stream
25+
video_stream = livekit.VideoStream(track)
26+
27+
@video_stream.on("frame_received")
28+
def on_video_frame(frame: livekit.VideoFrame):
29+
# received a video frame from the track
30+
pass
31+
```

0 commit comments

Comments
 (0)