@coze/realtime-api 1.2.1-beta.7 → 1.2.1-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/event-names/index.js +4 -4
- package/dist/cjs/index.js +38 -27
- package/dist/esm/event-names/index.js +4 -4
- package/dist/esm/index.js +38 -27
- package/dist/types/client.d.ts +1 -1
- package/dist/types/event-names/client.d.ts +1 -1
- package/dist/types/event-names/event-names.d.ts +5 -5
- package/dist/types/event-names.d.ts +5 -5
- package/dist/umd/index.js +38 -27
- package/package.json +1 -1
@@ -85,6 +85,10 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
|
|
85
85
|
* zh: 客户端视频关闭
|
86
86
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
87
87
|
/**
|
88
|
+
* en: Client video error
|
89
|
+
* zh: 客户端视频(或屏幕共享)错误
|
90
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
91
|
+
/**
|
88
92
|
* en: Client video event
|
89
93
|
* zh: 客户端视频事件
|
90
94
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -117,10 +121,6 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
|
|
117
121
|
* zh: 网络质量改变
|
118
122
|
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
119
123
|
/**
|
120
|
-
* en: Track ended
|
121
|
-
* zh: 断流事件
|
122
|
-
*/ EventNames["TRACK_ENDED"] = "client.track.ended";
|
123
|
-
/**
|
124
124
|
* en: Bot joined
|
125
125
|
* zh: Bot 加入
|
126
126
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
package/dist/cjs/index.js
CHANGED
@@ -198,6 +198,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
198
198
|
* zh: 客户端视频关闭
|
199
199
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
200
200
|
/**
|
201
|
+
* en: Client video error
|
202
|
+
* zh: 客户端视频(或屏幕共享)错误
|
203
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
204
|
+
/**
|
201
205
|
* en: Client video event
|
202
206
|
* zh: 客户端视频事件
|
203
207
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -230,10 +234,6 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
230
234
|
* zh: 网络质量改变
|
231
235
|
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
232
236
|
/**
|
233
|
-
* en: Track ended
|
234
|
-
* zh: 断流事件
|
235
|
-
*/ EventNames["TRACK_ENDED"] = "client.track.ended";
|
236
|
-
/**
|
237
237
|
* en: Bot joined
|
238
238
|
* zh: Bot 加入
|
239
239
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
@@ -422,8 +422,9 @@ class EngineClient extends RealtimeEventHandler {
|
|
422
422
|
downlinkNetworkQuality
|
423
423
|
});
|
424
424
|
}
|
425
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
425
426
|
handleTrackEnded(event) {
|
426
|
-
this.dispatch(event_names.
|
427
|
+
if ((null == event ? void 0 : event.kind) === 'video') this.dispatch(event_names.VIDEO_OFF, event);
|
427
428
|
}
|
428
429
|
async joinRoom(options) {
|
429
430
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
@@ -487,7 +488,12 @@ class EngineClient extends RealtimeEventHandler {
|
|
487
488
|
if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get audio devices');
|
488
489
|
if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get video devices');
|
489
490
|
await this.engine.startAudioCapture(devices.audioInputs[0].deviceId);
|
490
|
-
if (this._isSupportVideo)
|
491
|
+
if (this._isSupportVideo) try {
|
492
|
+
await this.setVideoInputDevice((null == videoConfig ? void 0 : videoConfig.videoInputDeviceId) || devices.videoInputs[0].deviceId, null == videoConfig ? void 0 : videoConfig.videoOnDefault);
|
493
|
+
this.dispatch((null == videoConfig ? void 0 : videoConfig.videoOnDefault) ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
494
|
+
} catch (e) {
|
495
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
496
|
+
}
|
491
497
|
}
|
492
498
|
async disconnect() {
|
493
499
|
try {
|
@@ -510,23 +516,18 @@ class EngineClient extends RealtimeEventHandler {
|
|
510
516
|
}
|
511
517
|
}
|
512
518
|
async changeVideoState(isVideoOn) {
|
513
|
-
|
514
|
-
if (
|
515
|
-
if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
516
|
-
else {
|
517
|
-
var _this__videoConfig;
|
518
|
-
this.engine.setVideoSourceType(rtc_namespaceObject.StreamIndex.STREAM_INDEX_SCREEN, rtc_namespaceObject.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
519
|
-
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
520
|
-
await this.engine.publishScreen(rtc_namespaceObject.MediaType.VIDEO);
|
521
|
-
}
|
522
|
-
} else if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
519
|
+
if (isVideoOn) {
|
520
|
+
if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
523
521
|
else {
|
524
|
-
|
525
|
-
|
522
|
+
var _this__videoConfig;
|
523
|
+
this.engine.setVideoSourceType(rtc_namespaceObject.StreamIndex.STREAM_INDEX_SCREEN, rtc_namespaceObject.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
524
|
+
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
525
|
+
await this.engine.publishScreen(rtc_namespaceObject.MediaType.VIDEO);
|
526
526
|
}
|
527
|
-
}
|
528
|
-
|
529
|
-
|
527
|
+
} else if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
528
|
+
else {
|
529
|
+
await this.engine.stopScreenCapture();
|
530
|
+
await this.engine.unpublishScreen(rtc_namespaceObject.MediaType.VIDEO);
|
530
531
|
}
|
531
532
|
}
|
532
533
|
async stop() {
|
@@ -752,10 +753,14 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
752
753
|
else this.dispatch(event_names.AUDIO_MUTED, {});
|
753
754
|
}
|
754
755
|
async setVideoEnable(isEnable) {
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
756
|
+
try {
|
757
|
+
var _this__client;
|
758
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.changeVideoState(isEnable));
|
759
|
+
this.dispatch(isEnable ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
760
|
+
} catch (e) {
|
761
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
762
|
+
throw e;
|
763
|
+
}
|
759
764
|
}
|
760
765
|
/**
|
761
766
|
* en: Enable audio properties reporting (debug mode only)
|
@@ -817,8 +822,14 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
817
822
|
*
|
818
823
|
* zh: 设置视频输入设备
|
819
824
|
*/ async setVideoInputDevice(deviceId) {
|
820
|
-
|
821
|
-
|
825
|
+
try {
|
826
|
+
var _this__client;
|
827
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
828
|
+
this.dispatch(event_names.VIDEO_ON, {});
|
829
|
+
} catch (e) {
|
830
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
831
|
+
throw e;
|
832
|
+
}
|
822
833
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
823
834
|
deviceId
|
824
835
|
});
|
@@ -48,6 +48,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
48
48
|
* zh: 客户端视频关闭
|
49
49
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
50
50
|
/**
|
51
|
+
* en: Client video error
|
52
|
+
* zh: 客户端视频(或屏幕共享)错误
|
53
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
54
|
+
/**
|
51
55
|
* en: Client video event
|
52
56
|
* zh: 客户端视频事件
|
53
57
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -80,10 +84,6 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
80
84
|
* zh: 网络质量改变
|
81
85
|
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
82
86
|
/**
|
83
|
-
* en: Track ended
|
84
|
-
* zh: 断流事件
|
85
|
-
*/ EventNames["TRACK_ENDED"] = "client.track.ended";
|
86
|
-
/**
|
87
87
|
* en: Bot joined
|
88
88
|
* zh: Bot 加入
|
89
89
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
package/dist/esm/index.js
CHANGED
@@ -171,6 +171,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
171
171
|
* zh: 客户端视频关闭
|
172
172
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
173
173
|
/**
|
174
|
+
* en: Client video error
|
175
|
+
* zh: 客户端视频(或屏幕共享)错误
|
176
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
177
|
+
/**
|
174
178
|
* en: Client video event
|
175
179
|
* zh: 客户端视频事件
|
176
180
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -203,10 +207,6 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
203
207
|
* zh: 网络质量改变
|
204
208
|
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
205
209
|
/**
|
206
|
-
* en: Track ended
|
207
|
-
* zh: 断流事件
|
208
|
-
*/ EventNames["TRACK_ENDED"] = "client.track.ended";
|
209
|
-
/**
|
210
210
|
* en: Bot joined
|
211
211
|
* zh: Bot 加入
|
212
212
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
@@ -393,8 +393,9 @@ class EngineClient extends RealtimeEventHandler {
|
|
393
393
|
downlinkNetworkQuality
|
394
394
|
});
|
395
395
|
}
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
396
397
|
handleTrackEnded(event) {
|
397
|
-
this.dispatch(event_names.
|
398
|
+
if ((null == event ? void 0 : event.kind) === 'video') this.dispatch(event_names.VIDEO_OFF, event);
|
398
399
|
}
|
399
400
|
async joinRoom(options) {
|
400
401
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
@@ -458,7 +459,12 @@ class EngineClient extends RealtimeEventHandler {
|
|
458
459
|
if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get audio devices');
|
459
460
|
if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get video devices');
|
460
461
|
await this.engine.startAudioCapture(devices.audioInputs[0].deviceId);
|
461
|
-
if (this._isSupportVideo)
|
462
|
+
if (this._isSupportVideo) try {
|
463
|
+
await this.setVideoInputDevice((null == videoConfig ? void 0 : videoConfig.videoInputDeviceId) || devices.videoInputs[0].deviceId, null == videoConfig ? void 0 : videoConfig.videoOnDefault);
|
464
|
+
this.dispatch((null == videoConfig ? void 0 : videoConfig.videoOnDefault) ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
465
|
+
} catch (e) {
|
466
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
467
|
+
}
|
462
468
|
}
|
463
469
|
async disconnect() {
|
464
470
|
try {
|
@@ -481,23 +487,18 @@ class EngineClient extends RealtimeEventHandler {
|
|
481
487
|
}
|
482
488
|
}
|
483
489
|
async changeVideoState(isVideoOn) {
|
484
|
-
|
485
|
-
if (
|
486
|
-
if (this._streamIndex === __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
487
|
-
else {
|
488
|
-
var _this__videoConfig;
|
489
|
-
this.engine.setVideoSourceType(__WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_SCREEN, __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
490
|
-
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
491
|
-
await this.engine.publishScreen(__WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.MediaType.VIDEO);
|
492
|
-
}
|
493
|
-
} else if (this._streamIndex === __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
490
|
+
if (isVideoOn) {
|
491
|
+
if (this._streamIndex === __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
494
492
|
else {
|
495
|
-
|
496
|
-
|
493
|
+
var _this__videoConfig;
|
494
|
+
this.engine.setVideoSourceType(__WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_SCREEN, __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
495
|
+
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
496
|
+
await this.engine.publishScreen(__WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.MediaType.VIDEO);
|
497
497
|
}
|
498
|
-
}
|
499
|
-
|
500
|
-
|
498
|
+
} else if (this._streamIndex === __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
499
|
+
else {
|
500
|
+
await this.engine.stopScreenCapture();
|
501
|
+
await this.engine.unpublishScreen(__WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.MediaType.VIDEO);
|
501
502
|
}
|
502
503
|
}
|
503
504
|
async stop() {
|
@@ -723,10 +724,14 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
723
724
|
else this.dispatch(event_names.AUDIO_MUTED, {});
|
724
725
|
}
|
725
726
|
async setVideoEnable(isEnable) {
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
727
|
+
try {
|
728
|
+
var _this__client;
|
729
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.changeVideoState(isEnable));
|
730
|
+
this.dispatch(isEnable ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
731
|
+
} catch (e) {
|
732
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
733
|
+
throw e;
|
734
|
+
}
|
730
735
|
}
|
731
736
|
/**
|
732
737
|
* en: Enable audio properties reporting (debug mode only)
|
@@ -788,8 +793,14 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
788
793
|
*
|
789
794
|
* zh: 设置视频输入设备
|
790
795
|
*/ async setVideoInputDevice(deviceId) {
|
791
|
-
|
792
|
-
|
796
|
+
try {
|
797
|
+
var _this__client;
|
798
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
799
|
+
this.dispatch(event_names.VIDEO_ON, {});
|
800
|
+
} catch (e) {
|
801
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
802
|
+
throw e;
|
803
|
+
}
|
793
804
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
794
805
|
deviceId
|
795
806
|
});
|
package/dist/types/client.d.ts
CHANGED
@@ -19,7 +19,7 @@ export declare class EngineClient extends RealtimeEventHandler {
|
|
19
19
|
handleUserLeave(event: onUserLeaveEvent): void;
|
20
20
|
handlePlayerEvent(event: unknown): void;
|
21
21
|
handleNetworkQuality(uplinkNetworkQuality: NetworkQuality, downlinkNetworkQuality: NetworkQuality): void;
|
22
|
-
handleTrackEnded(event:
|
22
|
+
handleTrackEnded(event: any): void;
|
23
23
|
joinRoom(options: {
|
24
24
|
token: string;
|
25
25
|
roomId: string;
|
@@ -19,7 +19,7 @@ export declare class EngineClient extends RealtimeEventHandler {
|
|
19
19
|
handleUserLeave(event: onUserLeaveEvent): void;
|
20
20
|
handlePlayerEvent(event: unknown): void;
|
21
21
|
handleNetworkQuality(uplinkNetworkQuality: NetworkQuality, downlinkNetworkQuality: NetworkQuality): void;
|
22
|
-
handleTrackEnded(event:
|
22
|
+
handleTrackEnded(event: any): void;
|
23
23
|
joinRoom(options: {
|
24
24
|
token: string;
|
25
25
|
roomId: string;
|
@@ -59,6 +59,11 @@ declare enum EventNames {
|
|
59
59
|
* zh: 客户端视频关闭
|
60
60
|
*/
|
61
61
|
VIDEO_OFF = "client.video.off",
|
62
|
+
/**
|
63
|
+
* en: Client video error
|
64
|
+
* zh: 客户端视频(或屏幕共享)错误
|
65
|
+
*/
|
66
|
+
VIDEO_ERROR = "client.video.error",
|
62
67
|
/**
|
63
68
|
* en: Client video event
|
64
69
|
* zh: 客户端视频事件
|
@@ -99,11 +104,6 @@ declare enum EventNames {
|
|
99
104
|
* zh: 网络质量改变
|
100
105
|
*/
|
101
106
|
NETWORK_QUALITY = "client.network.quality",
|
102
|
-
/**
|
103
|
-
* en: Track ended
|
104
|
-
* zh: 断流事件
|
105
|
-
*/
|
106
|
-
TRACK_ENDED = "client.track.ended",
|
107
107
|
/**
|
108
108
|
* en: Bot joined
|
109
109
|
* zh: Bot 加入
|
@@ -59,6 +59,11 @@ declare enum EventNames {
|
|
59
59
|
* zh: 客户端视频关闭
|
60
60
|
*/
|
61
61
|
VIDEO_OFF = "client.video.off",
|
62
|
+
/**
|
63
|
+
* en: Client video error
|
64
|
+
* zh: 客户端视频(或屏幕共享)错误
|
65
|
+
*/
|
66
|
+
VIDEO_ERROR = "client.video.error",
|
62
67
|
/**
|
63
68
|
* en: Client video event
|
64
69
|
* zh: 客户端视频事件
|
@@ -99,11 +104,6 @@ declare enum EventNames {
|
|
99
104
|
* zh: 网络质量改变
|
100
105
|
*/
|
101
106
|
NETWORK_QUALITY = "client.network.quality",
|
102
|
-
/**
|
103
|
-
* en: Track ended
|
104
|
-
* zh: 断流事件
|
105
|
-
*/
|
106
|
-
TRACK_ENDED = "client.track.ended",
|
107
107
|
/**
|
108
108
|
* en: Bot joined
|
109
109
|
* zh: Bot 加入
|
package/dist/umd/index.js
CHANGED
@@ -235,6 +235,10 @@
|
|
235
235
|
* zh: 客户端视频关闭
|
236
236
|
*/ EventNames["VIDEO_OFF"] = "client.video.off";
|
237
237
|
/**
|
238
|
+
* en: Client video error
|
239
|
+
* zh: 客户端视频(或屏幕共享)错误
|
240
|
+
*/ EventNames["VIDEO_ERROR"] = "client.video.error";
|
241
|
+
/**
|
238
242
|
* en: Client video event
|
239
243
|
* zh: 客户端视频事件
|
240
244
|
*/ EventNames["PLAYER_EVENT"] = "client.video.event";
|
@@ -267,10 +271,6 @@
|
|
267
271
|
* zh: 网络质量改变
|
268
272
|
*/ EventNames["NETWORK_QUALITY"] = "client.network.quality";
|
269
273
|
/**
|
270
|
-
* en: Track ended
|
271
|
-
* zh: 断流事件
|
272
|
-
*/ EventNames["TRACK_ENDED"] = "client.track.ended";
|
273
|
-
/**
|
274
274
|
* en: Bot joined
|
275
275
|
* zh: Bot 加入
|
276
276
|
*/ EventNames["BOT_JOIN"] = "server.bot.join";
|
@@ -460,8 +460,9 @@
|
|
460
460
|
downlinkNetworkQuality
|
461
461
|
});
|
462
462
|
}
|
463
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
463
464
|
handleTrackEnded(event) {
|
464
|
-
this.dispatch(event_names.
|
465
|
+
if ((null == event ? void 0 : event.kind) === 'video') this.dispatch(event_names.VIDEO_OFF, event);
|
465
466
|
}
|
466
467
|
async joinRoom(options) {
|
467
468
|
const { token, roomId, uid, audioMutedDefault, videoOnDefault, isAutoSubscribeAudio } = options;
|
@@ -525,7 +526,12 @@
|
|
525
526
|
if (!devices.audioInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get audio devices');
|
526
527
|
if (this._isSupportVideo && !devices.videoInputs.length) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, 'Failed to get video devices');
|
527
528
|
await this.engine.startAudioCapture(devices.audioInputs[0].deviceId);
|
528
|
-
if (this._isSupportVideo)
|
529
|
+
if (this._isSupportVideo) try {
|
530
|
+
await this.setVideoInputDevice((null == videoConfig ? void 0 : videoConfig.videoInputDeviceId) || devices.videoInputs[0].deviceId, null == videoConfig ? void 0 : videoConfig.videoOnDefault);
|
531
|
+
this.dispatch((null == videoConfig ? void 0 : videoConfig.videoOnDefault) ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
532
|
+
} catch (e) {
|
533
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
534
|
+
}
|
529
535
|
}
|
530
536
|
async disconnect() {
|
531
537
|
try {
|
@@ -548,23 +554,18 @@
|
|
548
554
|
}
|
549
555
|
}
|
550
556
|
async changeVideoState(isVideoOn) {
|
551
|
-
|
552
|
-
if (
|
553
|
-
if (this._streamIndex === rtc_.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
554
|
-
else {
|
555
|
-
var _this__videoConfig;
|
556
|
-
this.engine.setVideoSourceType(rtc_.StreamIndex.STREAM_INDEX_SCREEN, rtc_.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
557
|
-
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
558
|
-
await this.engine.publishScreen(rtc_.MediaType.VIDEO);
|
559
|
-
}
|
560
|
-
} else if (this._streamIndex === rtc_.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
557
|
+
if (isVideoOn) {
|
558
|
+
if (this._streamIndex === rtc_.StreamIndex.STREAM_INDEX_MAIN) await this.engine.startVideoCapture();
|
561
559
|
else {
|
562
|
-
|
563
|
-
|
560
|
+
var _this__videoConfig;
|
561
|
+
this.engine.setVideoSourceType(rtc_.StreamIndex.STREAM_INDEX_SCREEN, rtc_.VideoSourceType.VIDEO_SOURCE_TYPE_INTERNAL);
|
562
|
+
await this.engine.startScreenCapture(null === (_this__videoConfig = this._videoConfig) || void 0 === _this__videoConfig ? void 0 : _this__videoConfig.screenConfig);
|
563
|
+
await this.engine.publishScreen(rtc_.MediaType.VIDEO);
|
564
564
|
}
|
565
|
-
}
|
566
|
-
|
567
|
-
|
565
|
+
} else if (this._streamIndex === rtc_.StreamIndex.STREAM_INDEX_MAIN) await this.engine.stopVideoCapture();
|
566
|
+
else {
|
567
|
+
await this.engine.stopScreenCapture();
|
568
|
+
await this.engine.unpublishScreen(rtc_.MediaType.VIDEO);
|
568
569
|
}
|
569
570
|
}
|
570
571
|
async stop() {
|
@@ -790,10 +791,14 @@
|
|
790
791
|
else this.dispatch(event_names.AUDIO_MUTED, {});
|
791
792
|
}
|
792
793
|
async setVideoEnable(isEnable) {
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
794
|
+
try {
|
795
|
+
var _this__client;
|
796
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.changeVideoState(isEnable));
|
797
|
+
this.dispatch(isEnable ? event_names.VIDEO_ON : event_names.VIDEO_OFF, {});
|
798
|
+
} catch (e) {
|
799
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
800
|
+
throw e;
|
801
|
+
}
|
797
802
|
}
|
798
803
|
/**
|
799
804
|
* en: Enable audio properties reporting (debug mode only)
|
@@ -855,8 +860,14 @@
|
|
855
860
|
*
|
856
861
|
* zh: 设置视频输入设备
|
857
862
|
*/ async setVideoInputDevice(deviceId) {
|
858
|
-
|
859
|
-
|
863
|
+
try {
|
864
|
+
var _this__client;
|
865
|
+
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
866
|
+
this.dispatch(event_names.VIDEO_ON, {});
|
867
|
+
} catch (e) {
|
868
|
+
this.dispatch(event_names.VIDEO_ERROR, e);
|
869
|
+
throw e;
|
870
|
+
}
|
860
871
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
861
872
|
deviceId
|
862
873
|
});
|
package/package.json
CHANGED