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

@urtc/sdk-web

v2.0.0-beta.9

Published

UCloud RTC javascript SDK

Downloads

46

Readme

Web SDK

可参考 使用说明,并了解使用此 SDK 的简单步骤。

API

以下仅展示基本的 API 说明,更详细的 API 及类型说明,请参见 Docs

主要的类或接口

全局属性或方法

  • version - 当前 sdk 的版本号
  • createClient - 创建客户端
  • createStream - 创建本地流
  • deviceDetection - 设备可用性检测,创建包含麦克风音频或摄像头视频的本地流时,有可能因为麦克风或摄像头设备问题(如驱动问题,或未经授权等),导致无法正确创建。此方法可用于设备检测,根据检测结果,再决定创建本地流时启用麦克风或摄像头或麦克风和摄像头
  • generateToken - 根据 AppId,AppKey,RoomId,UserId 生成 token,用于开发阶段临时快速的加入房间并验证功能,由于 AppKey 不可暴露于公网,因此生产环境中不建议使用此方法生成 token
  • getCameras - 获取摄像头设备列表
  • getDevices - 获取音视频输入/输出设备列表
  • getLoudspeakers - 获取扬声器设备列表
  • getMicrophones - 获取麦克风设备列表
  • isSupportScreenShare - 检测浏览器是否支持屏幕共享
  • isSupportWebRTC - 检测浏览器是否完全(可访问本地音视频设备)支持 WebRTC
  • getSupportedCodec - 检测浏览器支持的WebRTC的音视频编解码格式
  • enableUploadLog - 开启日志(操作/错误/状态)的上报
  • disableUploadLog - 关闭日志(操作/错误/状态)的上报
  • setLogLevel - 设置日志打印级别,用于打印出更多日志来调试或定位问题
  • setServers - 用于私有化部署时,指定部署的服务器地址

Client

Client 对象包含以下方法:

Stream

Stream 为 LocalStream 及 RemoteStream 的父类

LocalStream

LocalStream 对象包含以下属性:

LocalStream 对象包含以下方法:

  • addTrack - 添加一条媒体轨道(音轨或视轨)到当前流
  • destroy - 销毁当前流,一般在本地流不再被使用时,可调用此方法销毁,解除摄像头或麦克风设备的占用
  • getAudioLevel - 获取当前流的音量大小,只有当本地流或远端流中有音频数据才有效
  • getMediaType - 获取流的媒体类型,主视频流/辅助视频流
  • getStats - 获取流发布或订阅后的统计数据
  • hasAudio - 判断当前流是否有音频
  • hasVideo - 判断当前流是否有视频
  • init - 初始化本地流对象,将读取麦克风、摄像头、屏幕共享等来初始化媒体流
  • muteAudio - mute 当前流的音频
  • muteVideo - mute 当前流的视频
  • off - 取消监听流对象事件
  • on - 监听流对象事件,可监听的事件类型有 RtcStreamEventTypeRtcPlayerEventType
  • play - 播放当前流
  • removeTrack - 从当前流中删除一条媒体轨道(音轨或视轨)
  • replaceTrack - 替换当前流中的媒体轨道
  • resume - 恢复播放流,一般由于浏览器限制无法自动播放时,可提示用户手动触发该方法进行恢复播放
  • setScreenProfile - 设置当前流(屏幕共享时)视频的 Profile,默认 '1080p'
  • setVideoProfile - 设置当前流视频的 Profile,默认 '360p_2'
  • snapshot - 对当前流进行截屏
  • stop - 停止播放当前流
  • switchDevice - 切换音视频设备
  • switchImage - 切换图片 - 使用图片生成视频,并将当前流的视频使用其代替
  • unmuteAudio - unmute 当前流的音频
  • unmuteVideo - unmute 当前流的视频

RemoteStream

RemoteStream 对象包含以下属性:

  • audioMuted - 当前流是否 mute 了音频
  • id - 当前流ID
  • mediaStream - 当前流包含的媒体流,关于媒体流,请详见 MediaStream
  • sourceAudioMuted - 音频源是否已 mute,当源端 mute/unmute 音频时,本端将收到 mute-audio 或 unmute-audio 事件的通知,同时此值将变为对应值
  • sourceVideoMuted - 视频源是否已 mute,当源端 mute/unmute 视频时,本端将收到 mute-video 或 unmute-video 事件的通知,同时此值将变为对应值
  • userId - 该流所属用户的ID
  • videoMuted - 当前流是否 mute 了视频

RemoteStream 对象包含以下方法:

User

  • id - 用户ID