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

react-select-media-devices-modal

v1.2.2

Published

A React component library for select media devices

Downloads

64

Readme

react-select-media-devices-modal

npm version Test E2E Test Release Deploy to GitHub Pages License: MIT

A React component library for select media devices.

Features

  • Select audio input, audio output, and video input device.
  • Show preview media stream get from selected device.
  • Record sample audio stream and play.

Demo

https://kadoshita.github.io/react-select-media-devices-modal/example/

Installation

npm install --save react-select-media-devices-modal

Usage

SelectMediaDevicesModal

import { useState } from 'react';
import { SelectMediaDevicesModal } from 'react-select-media-devices-modal';

function App() {
    const [modalOpen, setModalOpen] = useState(false);

    const handleDeviceSelected = (devices) => {
        setModalOpen(false);
        console.log(devices);
    };

    const handleDeviceSelectCanceled = () => {
        setModalOpen(false);
    };

    return (
        <div>
            <button onClick={() => setModalOpen((current) => !current)}>Select Device</button>
            <SelectMediaDevicesModal
                isSelectAudioInput
                isSelectAudioOutput
                isSelectVideoInput
                open={modalOpen}
                audioInputDeviceLabel="Audio input device"
                audioOutputDeviceLabel="Audio output device"
                videoInputDeviceLabel="Video input device"
                confirmButtonText="Confirm"
                cancelButtonText="Cancel"
                allowOutsideClick={false}
                onDeviceSelected={handleDeviceSelected}
                onDeviceSelectCanceled={handleDeviceSelectCanceled}
            ></SelectMediaDevicesModal>
        </div>
    );
}

export default App;

SelectMediaDevicesPreviewModal

import { useState } from 'react';
import { SelectMediaDevicesPreviewModal } from 'react-select-media-devices-modal';

function App() {
    const [modalOpen, setModalOpen] = useState(false);

    const handleDeviceSelected = (devices) => {
        setModalOpen(false);
        console.log(devices);
    };

    const handleDeviceSelectCanceled = () => {
        setModalOpen(false);
    };

    return (
        <div>
            <button onClick={() => setModalOpen((current) => !current)}>Select Device</button>
            <SelectMediaDevicesPreviewModal
                isSelectAudioInput
                isSelectAudioOutput
                isSelectVideoInput
                open={modalOpen}
                audioInputDeviceLabel="Audio input device"
                audioOutputDeviceLabel="Audio output device"
                videoInputDeviceLabel="Video input device"
                confirmButtonText="Confirm"
                cancelButtonText="Cancel"
                allowOutsideClick={false}
                onDeviceSelected={handleDeviceSelected}
                onDeviceSelectCanceled={handleDeviceSelectCanceled}
            ></SelectMediaDevicesPreviewModal>
        </div>
    );
}

export default App;

SelectMediaDevicesRecordingModal

import { useState } from 'react';
import { SelectMediaDevicesRecordingModal } from 'react-select-media-devices-modal';

function App() {
    const [modalOpen, setModalOpen] = useState(false);

    const handleDeviceSelected = (devices) => {
        setModalOpen(false);
        console.log(devices);
    };

    const handleDeviceSelectCanceled = () => {
        setModalOpen(false);
    };

    return (
        <div>
            <button onClick={() => setModalOpen((current) => !current)}>Select Device</button>
            <SelectMediaDevicesRecordingModal
                isSelectAudioInput
                isSelectAudioOutput
                isSelectVideoInput
                open={modalOpen}
                audioInputDeviceLabel="Audio input device"
                audioOutputDeviceLabel="Audio output device"
                videoInputDeviceLabel="Video input device"
                confirmButtonText="Confirm"
                cancelButtonText="Cancel"
                recordingButtonText="Recording"
                allowOutsideClick={false}
                onDeviceSelected={handleDeviceSelected}
                onDeviceSelectCanceled={handleDeviceSelectCanceled}
            ></SelectMediaDevicesRecordingModal>
        </div>
    );
}

export default App;

Props

SelectMediaDevicesModalProps

| Name | Type | Default | Description | | :--- | :--- | :------ | :---------- | | isSelectAudioInput | boolean | true | Flag that select an audio input device or not. | | isSelectAudioOutput | boolean | true | Flag that select an audio output device or not. | | isSelectVideoInput | boolean | true | Flag that select a video input device or not. | | open | boolean | false | Flag that open the modal or not. | | audioInputDeviceLabel | string | 'audio input device' | Label for list of audio input devices. | | audioOutputDeviceLabel | string | 'audio output device' | Label for list of audio output devices. | | videoInputDeviceLabel | string | 'video input device' | Label for list of video input devices. | | confirmButtonText | string | 'Confirm' | Label for the confirm button. | | cancelButtonText | string | 'Cancel' | Label for the cancel button. | | allowOutsideClick | boolean | true | Flag that cancel selection when clicking outside of the modal. | | onDeviceSelected | function | (devices: { audioInput?: MediaDeviceInfo; audioOutput?: MediaDeviceInfo; videoInput?: MediaDeviceInfo; }) => void | Handler function called when devices are selected. | | onDeviceSelectCanceled | function | () => void | Handler function called when selection canceled. |

SelectMediaDevicesPreviewModalProps

| Name | Type | Default | Description | | :--- | :--- | :------ | :---------- | | isSelectAudioInput | boolean | true | Flag that select an audio input device or not. | | isSelectAudioOutput | boolean | true | Flag that select an audio output device or not. | | isSelectVideoInput | boolean | true | Flag that select a video input device or not. | | open | boolean | false | Flag that open the modal or not. | | audioInputDeviceLabel | string | 'audio input device' | Label for list of audio input devices. | | audioOutputDeviceLabel | string | 'audio output device' | Label for list of audio output devices. | | videoInputDeviceLabel | string | 'video input device' | Label for list of video input devices. | | confirmButtonText | string | 'Confirm' | Label for the confirm button. | | cancelButtonText | string | 'Cancel' | Label for the cancel button. | | allowOutsideClick | boolean | true | Flag that cancel selection when clicking outside of the modal. | | onDeviceSelected | function | (devices: { audioInput?: MediaDeviceInfo; audioOutput?: MediaDeviceInfo; videoInput?: MediaDeviceInfo; }) => void | Handler function called when devices are selected. | | onDeviceSelectCanceled | function | () => void | Handler function called when selection canceled. |

SelectMediaDevicesRecordingModalProps

| Name | Type | Default | Description | | :--- | :--- | :------ | :---------- | | isSelectAudioInput | boolean | true | Flag that select an audio input device or not. | | isSelectAudioOutput | boolean | true | Flag that select an audio output device or not. | | isSelectVideoInput | boolean | true | Flag that select a video input device or not. | | open | boolean | false | Flag that open the modal or not. | | audioInputDeviceLabel | string | 'audio input device' | Label for list of audio input devices. | | audioOutputDeviceLabel | string | 'audio output device' | Label for list of audio output devices. | | videoInputDeviceLabel | string | 'video input device' | Label for list of video input devices. | | confirmButtonText | string | 'Confirm' | Label for the confirm button. | | cancelButtonText | string | 'Cancel' | Label for the cancel button. | | recordingButtonText | string | 'Recording' | Label for the recording button. | | allowOutsideClick | boolean | true | Flag that cancel selection when clicking outside of the modal. | | onDeviceSelected | function | (devices: { audioInput?: MediaDeviceInfo; audioOutput?: MediaDeviceInfo; videoInput?: MediaDeviceInfo; }) => void | Handler function called when devices are selected. | | onDeviceSelectCanceled | function | () => void | Handler function called when selection canceled. |

LICENSE

MIT

Author

Yoshiki Kadoshita

Contributors