Skip to content

RtcPublisher

用于将本地媒体流推送到流媒体服务器。

构造函数

typescript
new RtcPublisher(options: RtcPublisherOptions)

方法

start() 异步

开始推流。

typescript
await publisher.start();

stop()

停止推流。

typescript
publisher.stop();

switchSource(source) 异步

切换输入源,无需重建连接。

typescript
await publisher.switchSource({ type: 'screen', audio: true });

getStream()

获取本地 MediaStream。

typescript
const stream = publisher.getStream();

destroy()

销毁实例,释放资源。

typescript
publisher.destroy();

事件

事件说明
state连接状态
streamstart推流开始
streamstop推流停止
sourcechange输入源切换
permissiondenied权限拒绝
error错误
iceconnectionstateICE 连接状态

详见 推流指南PublisherOptions

基于 MIT 许可证发布