Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-media-devices

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-media-devices

JavaScript MediaDevices Manage Api. Video, Audio Device Manage.

  • 4.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
increased by350%
Maintainers
1
Weekly downloads
 
Created
Source

Js Media Devices

npm version npm Github file size license GitHub last commit

Manage Media Devices use javascript.

The MediaDevices interface provides access to connected media input devices like cameras and microphones.

Usage

Install

npm i js-media-devices

API

checkMediaDevicesSupport()

检查浏览器是否支持 MediaDevices

Return type

是或否

boolean
getAudioDeviceList()

获取音频设备列表(输入+输出)

Return type

音频设备信息列表

Promise<MediaDeviceInfo[]>
getAudioMediaStream(deviceId)

根据设备 ID 获取对应的音频输出流

Parameters

  • deviceId (string) – 设备 ID

Return type

音频流

Promise<MediaStream>
getAudioOutDeviceList()

获取音频输出设备列表

Return type

音频设备信息列表

Promise<MediaDeviceInfo[]>
getDeviceList()

授权并获取设备列表(所有)

Return type

媒体设备信息列表

Promise<MediaDeviceInfo[]>
getAudioInDeviceList()

获取音频输入设备列表

Return type

音频设备信息列表

Promise<MediaDeviceInfo[]>
getOnlyAudioDeviceList()

只授权音频设备并获取音频设备列表

Return type

音频设备信息列表

Promise<MediaDeviceInfo[]>
getOnlyVideoDeviceList()

只授权视频并获取视频设备列表

Return type

视频设备信息列表

Promise<MediaDeviceInfo[]>
getVideoAndAudioMediaStream(videoDeviceId, audioDeviceId)

根据视频输入设备 ID 和音频输入设备 ID 获取相应媒体流

Parameters

  • videoDeviceId (string) – 视频输入设备 ID
  • audioDeviceId (string) – 音频输入设备 ID

Return type

媒体流

Promise<MediaStream>
getVideoDeviceList()

获取视频输入设备列表

Return type

视频设备信息列表

Promise<MediaDeviceInfo[]>
getVideoMediaStream(deviceId [, options])

根据设备 ID 获取对应的视频输出流

Parameters

  • deviceId (string) – 设备 ID
  • options (any) – Optional. 选项 { minWidth, minHeight, width, height }

Return type

视频流

Promise<MediaStream>
setAudioOutDevice(element, deviceId)

根据音频输出设备 ID 设置当前音频输出设备

Parameters

  • element (HTMLAudioElement) – HTMLAudioElement
  • deviceId (string) – 音频输出设备 ID

Return type

提示信息

Promise<string>
stopMediaTracks(stream)

停止视频流/音频流

Parameters

  • stream (MediaStream) – 视频流或音频流

Return type

void

Example

import JsMediaDevices from "js-media-devices";

const device = new JsMediaDevices()(async () => {
  await device.getDeviceList(); // find out: src/index.js

  await device.setOutAudioDevices(element, deviceId);
})();

Build

yarn global add uglify-js

Keywords

FAQs

Package last updated on 15 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc