npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@chime/devices

v0.1.0-beta.4

Published

This package contains a React context provider and a hook around the [AWS Chime SDK](https://aws.amazon.com/chime/chime-sdk/). It allows you to get a list of audio/video devices and select a current device which it will keep in state.

Downloads

1

Readme

@chime/devices

This package contains a React context provider and a hook around the AWS Chime SDK. It allows you to get a list of audio/video devices and select a current device which it will keep in state.

Install

This package has a peer dependency on amazon-chime-sdk-js.

You can install the package using npm like this.

$ npm i @chime/devices amazon-chime-sdk-js

or with Yarn.

$ yarn add @chime/devices amazon-chime-sdk-js

Use in your code

ChimeDevicesProvider

Wrap yout <App> (or your components that will be using devices) in a <ChimeDevicesProvider> as follows.

<ChimeDevicesProvider>
  <App />
</ChimeDevicesProvider>

Options props to <ChimeDevicesProvider> include.

deviceController

This is an optional DefaultDeviceController object. See AWS Chime documentation for more information.

You could pass a custom controller that has logging enabled, for example. It's also used to mock during testing.

initialAudioInputDeviceId

The initial audio input device id (i.e. microphone) to use. You could persist the user's choice and use this to initialize the selection. If you don't specify an id, it will defaut to the first device in the list.

initialAudioOutDeviceId

The initial audio output device id (i.e. speaker) to use. You could persist the user's choice and use this to initialize the selection. If you don't specify an id, it will defaut to the first device in the list.

initialVideoInputDeviceId

The initial video input device id (i.e. camera) to use. You could persist the user's choice and use this to initialize the selection. If you don't specify an id, it will defaut to the first device in the list.

useChimeDevices

You can call useChimeDevices in some child component which returns the following.

audioInputs

A list of audio input devices (i.e. microphones). type = {deviceId:string, label:string}[]

audioOutputs

A list of audio output devices (i.e. speakers).

videoInputs

A list of video input devices (i.e. cameras).

currentAudioInputDeviceId

The currently selected audio input device id or null.

currentAudioOutputDeviceId

The currently selected audio output device id or null.

currentVideoInputDeviceId

The currently selected video input device id or null.

deviceController

The AWS Chime SDK DefaultDeviceController used.

setAudioInput

A function to set the current audio input. Pass the deviceId of the new audio input.

setAudioOutput

A function to set the current audio output. Pass the deviceId of the new audio output.

setVideoInput

A function to set the current video input. Pass the deviceId of the new video input.

Example using useChimeDevices

const AudioInputDevices = () => {
  const {
    audioInputs,
    currentAudioInputDeviceId,
    setAudioInput,
  } = useChimeDevices();

  return (
    <ul>
      {audioInputs.map(({ deviceId, label }) => (
        <li key={deviceId} onClick={() => setAudioInput(deviceId)}>
          {label}
          {deviceId === currentAudioInputDeviceId && '[selected]'}
        </li>
      ))}
    </ul>
  );
};

Sample code live!

You can see an example running live on CodeSandbox

License

For use under the MIT License