aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
716 stars 472 forks source link

Enhance start Method to Support Immediate Retrieval of Remote Video Sources #2939

Closed funayamateppei closed 2 months ago

funayamateppei commented 3 months ago

Community Note

Tell us about your request

What do you want us to build?

The request is for the amazon-chime-sdk-js package.

Tell us about the problem you are trying to solve and why is it hard?

When attempting to retrieve the list of participants immediately after connecting to a call using start and then calling getRemoteVideoSources, an empty array is returned despite participants being present. It seems that the start method does not return an instance that can retrieve the list of participants right after the call connection.

It would be helpful if start could return an instance that allows retrieving the list of participants immediately. Alternatively, is there a method to retrieve the list of participants right when the call is connected?

Additionally, it would be helpful if the start method were asynchronous. Currently, we have to work around this by using setTimeout to wait for one second before attempting to retrieve the list of participants.

How are you currently solving a problem?

Currently, there is no effective workaround as the getRemoteVideoSources method returns an empty array immediately after connecting to a call. We are using setTimeout to wait for one second before calling getRemoteVideoSources, but this is not an ideal solution.

Additional context

const meetingConfig = new MeetingSessionConfiguration(sessionResponse.meeting, sessionResponse.attendee)
const meetingSession = new DefaultMeetingSession(meetingConfig, logger, deviceController)
meetingSession.audioVideo.start()

const videoSources = meetingSession.audioVideo.getRemoteVideoSources()
console.log(videoSources) // []

This code uses setTimeout to wait for one second before calling getRemoteVideoSources to retrieve the list of participants, as the method returns an empty array immediately after the call connection, despite participants being present.

setTimeout(() => {
  const videoSources = meetingSession.audioVideo.getRemoteVideoSources()
  console.log(videoSources)
}, 1000);
ltrung commented 2 months ago

start process is designed to be async and cannot return results until connection established with backend. Instead of using setTimeout, please use audioVideoDidStart event to know when the meeting connects and you can use that function. See https://github.com/aws/amazon-chime-sdk-js/blob/main/README.md#starting-a-session.