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-rtc-sdk

v4.2.7

Published

For publishing npm package anyrtc SDK (Web). Get more information from https://www.anyrtc.io.

Downloads

247

Readme


id: overview title: ArRTC Web SDK API Docs sidebar_label: Web API 概览

AnyRTC Web SDK API Reference

The AnyRTC Web SDK (WebRTC) is a JavaScript library loaded by an HTML web page. The Ar Web SDK NG library uses APIs in the web browser to establish connections and control the communication and live broadcast services.

Ensure that you use the HTTPS protocol or localhost, otherwise the error WEB_SECURITY_RESTRICT occurs.

注意:

本文适用于 anyrtc Web SDK,这是 anyrtc Web SDK 的全量重构版本。如果你使用的是旧版 anyrtc Web SDK,请参考这里

anyrtc Web SDK 是通过 HTML 网页加载的 JavaScript 和 Typescript 库。你可以使用 anyrtc Web SDK 在网页浏览器中调用 API 建立连接,控制音视频通话和直播服务。

anyrtc Web SDK 支持所有的主流浏览器,详见浏览器支持

请务必使用 HTTPS 协议或者 localhost,否则 SDK 无法正常工作。

核心方法

| 方法 | 描述 | | ----------------------------------------- | -------------- | | createClient | 创建本地客户端 |

本地音视频采集

| 方法 | 描述 | | ------------------------------------------------------------ | -------------------------------------- | | createMicrophoneAudioTrack | 通过麦克风创建一个音频轨道对象 | | createCameraVideoTrack | 通过摄像头创建一个视频轨道对象 | | createMicrophoneAndCameraTracks | 同时创建麦克风音频轨道和摄像头视频轨道 | | createScreenVideoTrack | 通过屏幕共享创建一个视频轨道对象 | | createBufferSourceAudioTrack | 通过音频文件创建一个音频轨道对象 | | createCustomAudioTrack | 创建一个自定义的音频轨道对象 | | createCustomVideoTrack | 创建一个自定义的视频轨道对象 |

媒体设备查询

| 方法 | 描述 | | ------------------------------------------------------------ | ---------------------------- | | getDevices | 获取媒体设备列表 | | getCameras | 获取摄像头列表 | | getMicrophones | 获取麦克风列表 | | getElectronScreenSources | 获取 Electron 屏幕共享源列表 |

日志管理

| 方法 | 描述 | | ----------------------------------------------------- | ---------------- | | enableLogUpload | 打开日志上传功能 | | disableLogUpload | 关闭日志上传功能 | | setLogLevel | 设置日志等级 |

全局事件回调

| 方法 | 描述 | | ------------------------------------------------------------ | -------------------------- | | onCameraChanged | 通知有摄像头设备插入或拔出 | | onMicrophoneChanged | 通知有麦克风设备插入或拔出 |

其他

| 方法 | 描述 | | ------------------------------------------------------------ | ------------------------------ | | checkSystemRequirements | 检测浏览器兼容性 | | getSupportedCodec | 获取支持的编码格式 |

ArRTCClient

调用 createClient 创建一个本地客户端对象 ArRTCClient,代表一个通话中的本地用户。ArRTCClient 类提供音视频通话的核心功能,主要包含以下方法。

| 方法 | 描述 | | --------------- | ---------------------------- | | join | 加入频道 | | leave | 离开频道 | | publish | 发布本地音视频轨道 | | unpublish | 取消发布本地音视频轨道 | | subscribe | 订阅远端用户的音视频轨道 | | unsubscribe | 取消订阅远端用户的音视频轨道 |

LocalTrack

LocalTrack 是 anyrtc Web SDK 中定义本地音视频轨道的抽象类,可用于本地播放和发布。

SDK 通过不同的方式创建不同的 LocalTrack,返回不同的 LocalTrack 派生类对象。以下列举了所有的 LocalTrack 派生类以及所对应的创建方式:

本地音频轨道

根据创建方式的不同,本地音频轨道可分为以下三种。其中 LocalAudioTrack 派生自 LocalTrackMicrophoneAudioTrackBufferSourceAudioTrack 派生自 LocalAudioTrack

| 本地音频轨道 | 描述 | | -------------------------- | ------------------------------------------------------------ | | LocalAudioTrack | 最基础的本地音频轨道对象,包含了基础的本地音频控制,如播放、设置音量控制。 通过调用 ArRTC.createCustomAudioTrack 创建。 | | MicrophoneAudioTrack | 本地麦克风音频轨道对象,比 LocalAudioTrack 多一些控制麦克风的方法。 通过调用 ArRTC.createMicrophoneAudioTrack 创建。 | | BufferSourceAudioTrack | 通过读取音频数据源创建的本地音频轨道,比基础的 LocalAudioTrack 多一些控制音频数据源的方法。 通过调用 ArRTC.createBufferSourceAudioTrack 创建。 |

本地视频轨道

根据创建方式的不同,本地视频可分为以下两种。其中 LocalVideoTrack 派生自 LocalTrackCameraVideoTrack 派生自 LocalVideoTrack

| 本地视频轨道 | 描述 | | -------------------- | ------------------------------------------------------------ | | LocalVideoTrack | 最基础的本地视频轨道对象,包含了基础的本地视频控制,如播放、美颜。 通过调用 ArRTC.createCustomVideoTrackArRTC.createScreenVideoTrack 创建。 | | CameraVideoTrack | 本地摄像头视频轨道对象,比 LocalVideoTrack 多一些控制摄像头和编码参数的方法。 通过调用 ArRTC.createCameraVideoTrack 创建。 |

RemoteTrack

RemoteTrack 是 anyrtc Web SDK 中用于定义远端音视频轨道的抽象类。

在实际操作中,你需要先调用 ArRTCClient.subscribe 订阅远端用户,然后从远端用户对象 ArRTCRemoteUser 中获取派生自 RemoteTrackRemoteAudioTrack 对象和 RemoteVideoTrack 对象。

引入方式

如果你通过 <script> 的方式引入 anyrtc Web SDK,可以通过访问 ArRTC.createClient 来获取导出的模块。

如果你通过 npm 或者模块化的方式引入 anyrtc Web SDK,可以通过以下方式访问 ArRTC:

import ArRTC from "ar-rtc-sdk";
console.log(ArRTC.createClient);

类型模块(用户 Typescript)

对于 Typescript 开发者,我们提供了 .d.ts 文件导出详细的类型定义。你可以查看 API 文档的 Global 页面,该页面列出了所有 SDK 导出的模块和类型。

import ArRTC, { IArRTCClient } from "ar-rtc-sdk";

const client: IArRTCClient = ArRTC.createClient();