You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
async def receive_frames(stream: rtc.VideoStream):
async for frame in video_stream:
# received a video frame from the track, process it here
pass
'Room' object has no attribute 'participants'
This code does not work (for me)
for participant in room.participants.items():
for publication in participant.track_publications.items():
print("track publication: %s", publication.sid)
INFO:root:connected to room [UUID]
Traceback (most recent call last):
File ".../check_room.py", line 46, in <module>
asyncio.run(main())
File ".../lib/python3.12/asyncio/runners.py", line 194, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File ".../lib/python3.12/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.12/asyncio/base_events.py", line 684, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File ".../check_room.py", line 40, in main
for participant in room.participants.items():
^^^^^^^^^^^^^^^^^
AttributeError: 'Room' object has no attribute 'participants'
Why not make the code easy to "just use"?
Why not just make the code easy to use or link to a working example from this section of the README?
Maybe something like this so we don't waste an hour digging through the source code when we are just trying to see what it does?
import os
import logging
import asyncio
from livekit import rtc
# Update this with a valid token
TOKEN = os.environ.get("LIVEKIT_TOKEN")
URL = os.environ.get("LIVEKIT_URL")
async def main():
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
room = rtc.Room()
@room.on("participant_connected")
def on_participant_connected(participant: rtc.RemoteParticipant):
logging.info(
"participant connected: %s %s", participant.sid, participant.identity)
async def receive_frames(stream: rtc.VideoStream):
async for frame in stream:
# received a video frame from the track, process it here
pass
# track_subscribed is emitted whenever the local participant is subscribed to a new track
@room.on("track_subscribed")
def on_track_subscribed(track: rtc.Track, publication: rtc.RemoteTrackPublication, participant: rtc.RemoteParticipant):
logging.info("track subscribed: %s", publication.sid)
if track.kind == rtc.TrackKind.KIND_VIDEO:
video_stream = rtc.VideoStream(track)
asyncio.ensure_future(receive_frames(video_stream))
# By default, autosubscribe is enabled. The participant will be subscribed to
# all published tracks in the room
await room.connect(URL, TOKEN)
logging.info("connected to room %s", room.name)
for identity, participant in room.remote_participants.items():
print(f"identity: {identity}")
print(f"participant: {participant}")
# Now participant is the RemoteParticipant object, not a tuple
print(f"participant sid: {participant.sid}")
print(f"participant identity: {participant.identity}")
print(f"participant name: {participant.name}")
print(f"participant kind: {participant.kind}")
print(f"participant track publications: {participant.track_publications}")
for tid, publication in participant.track_publications.items():
print(f"\ttrack id: {tid}")
print(f"\t\ttrack publication: {publication}")
print(f"\t\ttrack kind: {publication.kind}")
print(f"\t\ttrack name: {publication.name}")
print(f"\t\ttrack source: {publication.source}")
print(f"participant metadata: {participant.metadata}")
if __name__ == "__main__":
asyncio.run(main())
Versions
Versions of livekit I am testing with:
Package
Version
livekit
0.18.1
livekit-agents
0.11.3
livekit-api
0.8.0
livekit-plugins-deepgram
0.6.11
livekit-plugins-elevenlabs
0.7.7
livekit-plugins-openai
0.10.7
livekit-plugins-silero
0.7.3
livekit-protocol
0.7.0
The text was updated successfully, but these errors were encountered:
This example "Connecting to a room" would be super helpful if it worked.
Bad Variable Name
Pretty sure
video_stream
should bestream
'Room' object has no attribute 'participants'
This code does not work (for me)
Why not make the code easy to "just use"?
Why not just make the code easy to use or link to a working example from this section of the README?
Maybe something like this so we don't waste an hour digging through the source code when we are just trying to see what it does?
Versions
Versions of livekit I am testing with:
The text was updated successfully, but these errors were encountered: