amazon-chime-sdk-component-library-react icon indicating copy to clipboard operation
amazon-chime-sdk-component-library-react copied to clipboard

Slow network Indication

Open UsmanShafaqat007 opened this issue 1 year ago • 3 comments

I am trying to detect the slow network so I can notify the users in the meeting

please provide an indication for the slow network if already there then kindly provide me the link.

I have looked into this documentation 'https://aws.github.io/amazon-chime-sdk-component-library-react' and haven't found anything useful regarding my need.

UsmanShafaqat007 avatar Sep 13 '22 06:09 UsmanShafaqat007

Hi @UsmanShafaqat007 , SDK doesn't have an out-of-box network indicator at the moment.

SDK exposes the metrics from WebRTC stats via useMediaStreamMetrics hook. You can implement your own network indicator based on below two metrics exposed by useMediaStreamMetrics hook.

availableOutgoingBandwidth: number | null;
availableIncomingBandwidth: number | null;

Alternately, you can subscribe to the connectionDidBecomeGood, connectionDidBecomePoor, connectionDidSuggestStopVideo, connectionHealthDidChange events of AudioVideoObserver to notify your user about the connection status change.

To access audioVideoObserver in React Component Library, you can do it like this:

import { AudioVideoObserver } from 'amazon-chime-sdk-js';

const audioVideo = useAudioVideo();

useEffect(() => {
  if (!audioVideo) {
    return;
  }

  const observer: AudioVideoObserver = {
    connectionDidBecomePoor(): void {
      console.log('connection is poor');
    },
    connectionDidSuggestStopVideo(): void {
      console.log('suggest turning the video off');
    },
    connectionDidBecomeGood(): void {
      console.log('connection is good now');
    }
  };

  audioVideo.addObserver(observer);

  return () => audioVideo.removeObserver(observer);
}, [audioVideo]);

xuesichao avatar Sep 13 '22 17:09 xuesichao

You might find this Quality, Bandwidth, and Connectivity Guide from Amazon Chime SDK for JavaScript helpful.

I will leave this issue open as a feature request. Thank you.

xuesichao avatar Sep 13 '22 17:09 xuesichao