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

@dytesdk/device-emulator

v1.12.0

Published

Adds methods to emulate various devices on MediaDevices class.

Downloads

48

Readme

Table of Contents

About The Project

For a product, integration tests are one of the crucial part that improves quality & stability. For a WebRTC based solution like Dyte, having integration tests that can test multi-user call with Audio/Video on is necessary.

For an end user, sharing a camera & mic is easy. For this, browsers expose APIs such as enumerateDevices & getUserMedia on MediaDevices interface, on which user interfaces can be built easily.

Access to camera & mic prompts the users to allow permissions to do so. This works great as long as an end-user is using the product and actively allowing permissions and selecting devices, However this makes it impossible to write integration tests because for integration tests there is no active user and you need to somehow allow permissions programmatically which at the moment of writing this README is not reliably supported in modern tools like Playwright.

Even if we can somehow allow permissions, The next set of questions would be: What would the video & audio feed look like? Can we customize the feed? Can we use the feed to detect delays between a video feed producer and consumer? How do we test multiple devices? How do we test media ejection on the fly? How do we test addition of a new device?

Dyte's Device Emulator is a solution that answers all these questions and provides a easier way to mimic, add, remove devices & their feed.

Built With

  • Canvas
  • MediaDevices interface
  • Typescript

Getting Started

To get a local copy up and running, please follow these simple steps.

Prerequisites

  • Node.js
  • NPM

Installation

  1. Clone the repo
git clone https://github.com/dyte-io/device-emulator.git
  1. Install NPM packages
npm install

Usage

To test quickly, Run Device Emulator with a Dyte meeting

npm run dev

This would open a tab with localhost:3000 in it.

http://localhost:3000/?authToken=PUT_PARTICIPANT_AUTH_TOKEN_HERE

Replace PUT_PARTICIPANT_AUTH_TOKEN_HERE with actual participant token.

In case you are new to Dyte, Please make sure you've read the Getting Started with Dyte topic and completed the following steps:

  1. Create a Dyte Developer Account
  2. Create Presets. Dyte also includes the following pre-configured presets for group call and webinar. You can simply use the default preset such as group_call_host if you don't wish to create one.
  3. Create a Dyte Meeting
  4. Add Participant to the meeting

Adding participant to meeting would give you the desired auth token.

Once you are in the Dyte meeting, Go to Settings -> Video -> Select the emulated device. Turn the video on, if not on already. That's it.

In case you want to integrate the device-emulator solution in your product without a Dyte meeting, Add the below script tags in your code:

    <script>
        window.addEventListener('dyte.deviceEmulatorLoaded', () => {
            navigator.mediaDevices.addEmulatedDevice('videoinput');
        });
    </script>
    <script src="https://cdn.jsdelivr.net/npm/@dytesdk/device-emulator/dist/index.iife.js"></script>

This would add a fake videoinput emulated device.

Examples

Wait for the device emulator to load.

window.addEventListener('dyte.deviceEmulatorLoaded', () => {
    console.log('Device emulator loaded.')
});

Add a fake video input device

navigator.mediaDevices.addEmulatedDevice('videoinput');

Add a fake audio input device

navigator.mediaDevices.addEmulatedDevice('audioinput');

Remove a fake input device

Get the emulated device id using enumerateDevices api.

navigator.mediaDevices.enumerateDevices()

Find the device that you want to remove, keep the device id handy.

navigator.mediaDevices.removeEmulatedDevice('PUT_EMULATED_DEVICE_ID_HERE');

Roadmap

See the open issues for a list of proposed features (and known issues).

Few upcoming features are:

  1. Use any video file as a feed instead of Dyte's default video feed.
  2. Audio file support
  3. Browser-like constraints
  4. Custom device names

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated. Sincere thanks to all our contributors. Thank you, contributors!

You are requested to follow the contribution guidelines specified in CONTRIBUTING.md and code of conduct at CODE_OF_CONDUCT.md while contributing to the project :smile:.

Support

Contributions, issues, and feature requests are welcome! Give a ⭐️ if you like this project!

License

Distributed under the Apache License, Version 2.0. See LICENSE for more information.

About

device-emulator is created & maintained by Dyte, Inc. You can find us on Twitter - @dyte_io or write to us at dev [at] dyte.io.

The names and logos for Dyte are trademarks of dyte, Inc.

We love open source software! See our other projects and our products.