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

dingrtc

v3.5.0

Published

dingRTC web端 sdk

Downloads

114

Readme

Aliyun WebRtc SDK

阿里云音视频通信dingRtc,提供基于WebRTC适用于浏览器的SDK。

Installation

You can install it as dependency with npm/cnpm or yarn.

$ # save into package.json dependencies with -S
$ npm install dingrtc -S

$ # you can use cnpm for fast install
$ cnpm install dingrtc -S

$ # use yarn for install
$ yarn add dingrtc

一、接入前准备

阿里云RTC提供移动端、PC等多端SDK,并兼容标准WebRTC浏览器接入网络,帮助您快速搭建多端实时应用。接入RTC的方法,请参见接口文档。 当您成功搭建本地SDK,可以在终端调用API与RTC服务端进行交互,在加入频道或房间后,您可以进行本地推流、订阅远端用户等操作,实现频道内不同用户之间的音视频实时通话。 阿里云RTC拥有全球实时智能调度系统,并结合实时媒体处理系统和1500+边缘节点,运用行业领先的音频3A(AGC、AEC、ANS)、视频编码、弱网对抗等算法为您提供低延时、抗丢包的音视频实时通信。

二、快速开启

  • 创建实例
import DingRTC from 'dingrtc'

/**
 * 创建客户端实例
 */
const client = DingRTC.createClient();
  • 检测浏览器是否支持webrtc
const supported = DingRTC.checkSystemRequirements();
if (supported) {
  //支持webrtc
} else {
 //不支持webrtc
}
  • 订阅user-published回调。当远程用户推流时,在SDK里会触发user-published回调,通过订阅这个回调,能够得到频道里已经推流的用户。
client.on('user-published',(user, mediaType) =>{
    //远程发布者userId
    console.log(user.userId);
    //远程发布轨道类型
    console.log(mediaType);
  });
  • 加入频道
client.join({
    uid,         // 用户ID,只能由数字、字母、下划线组成
    channel,        // 频道名
    appId,          // 应用ID
    token,          // 令牌
    userName,       // 用户名 
}).then((response)=>{
    // 入会成功
    console.log(response.remoteUsers); // 打印已在会中成员
}).catch((error)=>{
    // 入会失败,打印错误内容,可以看到失败原因
    console.log(error.message);
});
  • 采集摄像头
const cameraTrack = await DingRTC.createCameraVideoTrack({
  frameRate: 15,
  dimension: 'VD_1280x720',
})
  • 采集麦克风
const micTrack = await DingRTC.createMicrophoneAudioTrack()
  • 推流
await client.publish([cameraTrack, micTrack]);
  • 订阅和显示远程流。通过subscribe方法订阅远程流,订阅成功后在调用track.play显示远程流。

通常在user-published回调中进行订阅与设置视图。

// 订阅指定用户视频
client.subscribe(userId, 'video').then((track)=>{
  track.play(`#${userId}`)
}).catch((error)=>{
    console.log(error.message);
});
// 订阅音频合流
client.subscribe('mcu', 'audio').then((track)=>{
  track.play()
}).catch((error)=>{
    console.log(error.message);
});
  • 离开频道。
client.leave();