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

ar-detect

v3.0.1

Published

this SDK form anyrtc developer group.

Downloads

31

Readme

一、概述

简介

anyRTC RTC 检测工具提供以下检测功能:

  • 浏览器webRTC检测
  • 获取浏览器信息、版本、以及操作系统
  • 分辨率检测
  • 音频大小检测
  • 获取设备信息
  • 媒体视频窗口截图等等

Dome体验

检测工具为您的产品带来更好的用户体验。

源码GitHub

源码仅供开发者参考,适用于SDK调试,便于快速集成。

二、集成指南

适用范围

本集成文档适用于Web ArDetect SDK 3.0.0及以上版本。

准备环境

支持 Chrome、IE 10 +、Firefox、Safari 等主流浏览器环境

导入SDK

npm 市场
npm install ar-detect --save-dev

import ArDetect from 'ar-detect';
  • 安装或更新至最新版本:
npm install ar-detect@latest --save-dev

import ArDetect from 'ar-detect';
js 引用
<script src="yourAssetsPath/ArDetect.版本号.js"></script>

三、API接口文档

ArDetect对象简介

示例
ArDetect = {
	browserInfo,//浏览器信息
	OSName,//操作系统信息
	checkRTCSupport(),//检测浏览器是否支持webRTC
	...
};

检测浏览器是否支持webRTC

示例
ArDetect.checkRTCSupport();

返回值

true or false

获取设备列表

ArDetect.getDevices(deviceType).then(data => {
	console.log(data);
}).catch(err => {
	console.log('getDevice error', err);
})
参数

| 参数名 | 类型 | 描述 | | ---------- | :----: | ------------------------------------------------------------ | | deviceType | string | 设备类型(非必选):'videoinput' 摄像头、'audioinput'麦克风、'audiooutput'扬声器 |

检测分辨率是否支持

示例
ArDetect.checkResolution(resolutionOptions); 
参数

| 参数名 | 类型 | 描述 | | ----------------- | ------ | ------------------------------------- | | resolutionOptions | object | width视频宽度height视频高度 |

说明

检测本地摄像头是否支持采集设定的分辨率。

返回值

Promise对象。

创建本地预览流(打开摄像头)

示例
ArDetect.createStream(constraints)
	.then(e => {
		//do something
	})
	.catch(err => {

	});

参数

| 参数名 | 类型 | 描述 | | ----------- | :----: | ---------------------- | | constraints | object | 采集媒体配置(非必填) |

constraints

| 参数名 | 类型 | 描述 | | ------ | :----: | ------------------------------------------------------------ | | video | object | enable是否打开摄像头deviceId指定设备,deviceId 通过getDevices 接口获取 | | audio | object | enable是否打开摄像头deviceId指定设备,deviceId 通过getDevices 接口获取 |

说明

返回Promise对象。

释放采集设备

示例
ArDetect.releaseStream();

检测媒体流音频

示例
let detectContext = ArDetect.detectMediaStreamVolum(stream, callback);
参数

| 参数名 | 类型 | 描述 | | -------- | :---------: | --------------------------------------------------- | | stream | mediaStream | 媒体流对象,例如:createStream返回的媒体流 | | callback | function | 获取媒体流音频大小成功的回调。参数为音频大小0~100 |

说明

获取指定媒体流的音频大小。

返回值

检测音频大小的上下文对象detectContext,结束音频检测时传入。

取消媒体流音频检测

示例
ArDetect.endDetectMediaStreamVolume(detectContext);
参数

| 参数名 | 类型 | 描述 | | ------------ | ------- | ------------------------------------------ | | audioContext | object | detectMediaStreamVolum时返回的上下文对象 |

说明

该方法需要在detectMediaStreamVolum调用之后才能调用。

选择音频输出设备

示例
ArDetect.attachSinkId(element, sinkId);
参数

| 参数名 | 类型 | 描述 | | ------------ | ------- | ------------------------------------------ | | element | element | audioDOM对象 | | sinkId | string | 扬声器的设备id(audiooutput), 通过getDeivces('audiooutput')获得 |

说明

获得设备列表,选择指定设备播放音频。

返回值

Promise

捕捉视频窗口截图

示例
ArDetect.takeMediaStreamSnapshot(videoElement, fileName);
参数

| 参数名 | 类型 | 描述 | | -------- | ------- | ---------------------------- | | enable | element | videoDOM对象 | | fileName | string | 文件名,下载到本地的文件名称 |

四、更新日志

Version 3.0.1 (2019-05-27)

  • 更新文档

Version 3.0.0 (2019-01-24)

  • SDK版本升级3.0,API接口变更,更加简洁规范