I am unable to obtain the mediaStreamTracks
for local and remote participants, even after the roomState
changes to connected. However, I noticed that they become available after reconnecting. Please advice how I could access the mediaStreamTracks
for both local and remote participants after connecting to the room.
To reproduce the bug try the following code in Room component of this repo.
// Below function is from room component of this repo
import useRoomState from '../../hooks/useRoomState/useRoomState';
import useVideoContext from '../useVideoContext/useVideoContext';
export default function Room() {
const { room } = useVideoContext();
const {
room: { localParticipant },
} = useVideoContext();
const [participants, setParticipants] = useState(Array.from(room.participants.values()));
const roomState = useRoomState();
useEffect(() => {
if(roomState === 'connected'){
localParticipant.tracks.forEach(track => {
if (track.kind === 'data' ) {
return;
}
console.log(track.mediaStreamTrack) // Getting undefined!!
}
participants.forEach(participant => {
participant.tracks.forEach(track => {
if (track.kind === 'data') {
return;
}
console.log(track.mediaStreamTrack) // Getting undefined!!
}
}
}, [roomState]);
}