@coze/realtime-api 1.2.0 → 1.2.1-beta.3
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 -0
- package/dist/cjs/index.js +31 -10
- package/dist/esm/event-names/index.js +4 -0
- package/dist/esm/index.js +31 -10
- package/dist/types/event-names/event-names.d.ts +5 -0
- package/dist/types/event-names/index.d.ts +8 -1
- package/dist/types/event-names/utils.d.ts +6 -0
- package/dist/types/event-names.d.ts +5 -0
- package/dist/types/index.d.ts +8 -1
- package/dist/types/utils.d.ts +6 -0
- package/dist/umd/index.js +31 -10
- package/package.json +2 -2
@@ -49,6 +49,10 @@ var EventNames = /*#__PURE__*/ function(EventNames) {
|
|
49
49
|
* zh: 所有服务端事件
|
50
50
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
51
51
|
/**
|
52
|
+
* en: Room info
|
53
|
+
* zh: 房间信息
|
54
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
55
|
+
/**
|
52
56
|
* en: Client connected
|
53
57
|
* zh: 客户端连接
|
54
58
|
*/ EventNames["CONNECTED"] = "client.connected";
|
package/dist/cjs/index.js
CHANGED
@@ -61,6 +61,7 @@ __webpack_require__.d(utils_namespaceObject, {
|
|
61
61
|
checkDevicePermission: ()=>checkDevicePermission,
|
62
62
|
checkPermission: ()=>checkPermission,
|
63
63
|
getAudioDevices: ()=>getAudioDevices,
|
64
|
+
isMobileVideoDevice: ()=>isMobileVideoDevice,
|
64
65
|
isScreenShareDevice: ()=>isScreenShareDevice,
|
65
66
|
isScreenShareSupported: ()=>isScreenShareSupported,
|
66
67
|
sleep: ()=>sleep
|
@@ -135,6 +136,11 @@ var rtc_default = /*#__PURE__*/ __webpack_require__.n(rtc_namespaceObject);
|
|
135
136
|
};
|
136
137
|
};
|
137
138
|
const isScreenShareDevice = (deviceId)=>'screenShare' === deviceId;
|
139
|
+
/**
|
140
|
+
* 判断是否前后置摄像头
|
141
|
+
* @param deviceId
|
142
|
+
* @returns
|
143
|
+
*/ const isMobileVideoDevice = (deviceId)=>'user' === deviceId || 'environment' === deviceId;
|
138
144
|
/**
|
139
145
|
* Check if browser supports screen sharing
|
140
146
|
* 检查浏览器是否支持屏幕共享
|
@@ -156,6 +162,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
156
162
|
* zh: 所有服务端事件
|
157
163
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
158
164
|
/**
|
165
|
+
* en: Room info
|
166
|
+
* zh: 房间信息
|
167
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
168
|
+
/**
|
159
169
|
* en: Client connected
|
160
170
|
* zh: 客户端连接
|
161
171
|
*/ EventNames["CONNECTED"] = "client.connected";
|
@@ -439,7 +449,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
439
449
|
const devices = await getAudioDevices({
|
440
450
|
video: true
|
441
451
|
});
|
442
|
-
if (-1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
452
|
+
if (!isMobileVideoDevice(deviceId) && -1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
443
453
|
await this.changeVideoState(false);
|
444
454
|
if (isScreenShareDevice(deviceId)) {
|
445
455
|
if (this._streamIndex === rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN) this.engine.setLocalVideoPlayer(rtc_namespaceObject.StreamIndex.STREAM_INDEX_MAIN);
|
@@ -620,16 +630,16 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
620
630
|
// Step1 get token
|
621
631
|
if (getRoomInfo) roomInfo = await getRoomInfo();
|
622
632
|
else {
|
623
|
-
|
624
|
-
if (this._config.
|
625
|
-
|
633
|
+
const config = {};
|
634
|
+
if (this._config.prologueContent) config.prologue_content = this._config.prologueContent;
|
635
|
+
if (this._config.videoConfig) {
|
636
|
+
if (isScreenShareDevice(this._config.videoConfig.videoInputDeviceId)) config.video_config = {
|
626
637
|
stream_video_type: 'screen'
|
627
|
-
}
|
628
|
-
|
629
|
-
video_config: {
|
638
|
+
};
|
639
|
+
else config.video_config = {
|
630
640
|
stream_video_type: 'main'
|
631
|
-
}
|
632
|
-
}
|
641
|
+
};
|
642
|
+
}
|
633
643
|
roomInfo = await this._api.audio.rooms.create({
|
634
644
|
bot_id: botId,
|
635
645
|
conversation_id: conversationId || void 0,
|
@@ -644,6 +654,12 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
644
654
|
this.dispatch(event_names.ERROR, error);
|
645
655
|
throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
|
646
656
|
}
|
657
|
+
this.dispatch(event_names.ROOM_INFO, {
|
658
|
+
roomId: roomInfo.room_id,
|
659
|
+
uid: roomInfo.uid,
|
660
|
+
token: roomInfo.token,
|
661
|
+
appId: roomInfo.app_id
|
662
|
+
});
|
647
663
|
this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
|
648
664
|
// Step2 create engine
|
649
665
|
this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
|
@@ -785,7 +801,11 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
785
801
|
deviceId
|
786
802
|
});
|
787
803
|
}
|
788
|
-
|
804
|
+
/**
|
805
|
+
* en: Set the video input device
|
806
|
+
*
|
807
|
+
* zh: 设置视频输入设备
|
808
|
+
*/ async setVideoInputDevice(deviceId) {
|
789
809
|
var _this__client;
|
790
810
|
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
791
811
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
@@ -842,6 +862,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
842
862
|
* 可选,视频输入设备的设备 ID。
|
843
863
|
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
844
864
|
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
865
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
845
866
|
*/ constructor(config){
|
846
867
|
super(config.debug), this._client = null, this.isConnected = false, this._isTestEnv = false, this._isSupportVideo = false;
|
847
868
|
this._config = config;
|
@@ -12,6 +12,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
12
12
|
* zh: 所有服务端事件
|
13
13
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
14
14
|
/**
|
15
|
+
* en: Room info
|
16
|
+
* zh: 房间信息
|
17
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
18
|
+
/**
|
15
19
|
* en: Client connected
|
16
20
|
* zh: 客户端连接
|
17
21
|
*/ EventNames["CONNECTED"] = "client.connected";
|
package/dist/esm/index.js
CHANGED
@@ -37,6 +37,7 @@ __webpack_require__.d(utils_namespaceObject, {
|
|
37
37
|
checkDevicePermission: ()=>checkDevicePermission,
|
38
38
|
checkPermission: ()=>checkPermission,
|
39
39
|
getAudioDevices: ()=>getAudioDevices,
|
40
|
+
isMobileVideoDevice: ()=>isMobileVideoDevice,
|
40
41
|
isScreenShareDevice: ()=>isScreenShareDevice,
|
41
42
|
isScreenShareSupported: ()=>isScreenShareSupported,
|
42
43
|
sleep: ()=>sleep
|
@@ -108,6 +109,11 @@ __webpack_require__.d(utils_namespaceObject, {
|
|
108
109
|
};
|
109
110
|
};
|
110
111
|
const isScreenShareDevice = (deviceId)=>'screenShare' === deviceId;
|
112
|
+
/**
|
113
|
+
* 判断是否前后置摄像头
|
114
|
+
* @param deviceId
|
115
|
+
* @returns
|
116
|
+
*/ const isMobileVideoDevice = (deviceId)=>'user' === deviceId || 'environment' === deviceId;
|
111
117
|
/**
|
112
118
|
* Check if browser supports screen sharing
|
113
119
|
* 检查浏览器是否支持屏幕共享
|
@@ -129,6 +135,10 @@ var event_names_EventNames = /*#__PURE__*/ function(EventNames) {
|
|
129
135
|
* zh: 所有服务端事件
|
130
136
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
131
137
|
/**
|
138
|
+
* en: Room info
|
139
|
+
* zh: 房间信息
|
140
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
141
|
+
/**
|
132
142
|
* en: Client connected
|
133
143
|
* zh: 客户端连接
|
134
144
|
*/ EventNames["CONNECTED"] = "client.connected";
|
@@ -410,7 +420,7 @@ class EngineClient extends RealtimeEventHandler {
|
|
410
420
|
const devices = await getAudioDevices({
|
411
421
|
video: true
|
412
422
|
});
|
413
|
-
if (-1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
423
|
+
if (!isMobileVideoDevice(deviceId) && -1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
414
424
|
await this.changeVideoState(false);
|
415
425
|
if (isScreenShareDevice(deviceId)) {
|
416
426
|
if (this._streamIndex === __WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_MAIN) this.engine.setLocalVideoPlayer(__WEBPACK_EXTERNAL_MODULE__volcengine_rtc__.StreamIndex.STREAM_INDEX_MAIN);
|
@@ -591,16 +601,16 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
591
601
|
// Step1 get token
|
592
602
|
if (getRoomInfo) roomInfo = await getRoomInfo();
|
593
603
|
else {
|
594
|
-
|
595
|
-
if (this._config.
|
596
|
-
|
604
|
+
const config = {};
|
605
|
+
if (this._config.prologueContent) config.prologue_content = this._config.prologueContent;
|
606
|
+
if (this._config.videoConfig) {
|
607
|
+
if (isScreenShareDevice(this._config.videoConfig.videoInputDeviceId)) config.video_config = {
|
597
608
|
stream_video_type: 'screen'
|
598
|
-
}
|
599
|
-
|
600
|
-
video_config: {
|
609
|
+
};
|
610
|
+
else config.video_config = {
|
601
611
|
stream_video_type: 'main'
|
602
|
-
}
|
603
|
-
}
|
612
|
+
};
|
613
|
+
}
|
604
614
|
roomInfo = await this._api.audio.rooms.create({
|
605
615
|
bot_id: botId,
|
606
616
|
conversation_id: conversationId || void 0,
|
@@ -615,6 +625,12 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
615
625
|
this.dispatch(event_names.ERROR, error);
|
616
626
|
throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
|
617
627
|
}
|
628
|
+
this.dispatch(event_names.ROOM_INFO, {
|
629
|
+
roomId: roomInfo.room_id,
|
630
|
+
uid: roomInfo.uid,
|
631
|
+
token: roomInfo.token,
|
632
|
+
appId: roomInfo.app_id
|
633
|
+
});
|
618
634
|
this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
|
619
635
|
// Step2 create engine
|
620
636
|
this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
|
@@ -756,7 +772,11 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
756
772
|
deviceId
|
757
773
|
});
|
758
774
|
}
|
759
|
-
|
775
|
+
/**
|
776
|
+
* en: Set the video input device
|
777
|
+
*
|
778
|
+
* zh: 设置视频输入设备
|
779
|
+
*/ async setVideoInputDevice(deviceId) {
|
760
780
|
var _this__client;
|
761
781
|
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
762
782
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
@@ -813,6 +833,7 @@ class RealtimeClient extends RealtimeEventHandler {
|
|
813
833
|
* 可选,视频输入设备的设备 ID。
|
814
834
|
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
815
835
|
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
836
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
816
837
|
*/ constructor(config){
|
817
838
|
super(config.debug), this._client = null, this.isConnected = false, this._isTestEnv = false, this._isSupportVideo = false;
|
818
839
|
this._config = config;
|
@@ -30,6 +30,7 @@ export interface RealtimeClientConfig {
|
|
30
30
|
suppressNonStationaryNoise?: boolean /** optional, Suppress non-stationary noise, defaults to false */;
|
31
31
|
videoConfig?: VideoConfig /** optional, Video configuration */;
|
32
32
|
isAutoSubscribeAudio?: boolean /** optional, Whether to automatically subscribe to bot reply audio streams, defaults to true */;
|
33
|
+
prologueContent?: string /** optional, Prologue content */;
|
33
34
|
}
|
34
35
|
declare class RealtimeClient extends RealtimeEventHandler {
|
35
36
|
_config: RealtimeClientConfig;
|
@@ -80,6 +81,7 @@ declare class RealtimeClient extends RealtimeEventHandler {
|
|
80
81
|
* 可选,视频输入设备的设备 ID。
|
81
82
|
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
82
83
|
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
84
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
83
85
|
*/
|
84
86
|
constructor(config: RealtimeClientConfig);
|
85
87
|
/**
|
@@ -143,7 +145,12 @@ declare class RealtimeClient extends RealtimeEventHandler {
|
|
143
145
|
* zh: 设置音频输出设备
|
144
146
|
*/
|
145
147
|
setAudioOutputDevice(deviceId: string): Promise<void>;
|
146
|
-
|
148
|
+
/**
|
149
|
+
* en: Set the video input device
|
150
|
+
*
|
151
|
+
* zh: 设置视频输入设备
|
152
|
+
*/
|
153
|
+
setVideoInputDevice(deviceId: string | 'screenShare' | 'user' | 'environment'): Promise<void>;
|
147
154
|
/**
|
148
155
|
* en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
|
149
156
|
*
|
@@ -36,6 +36,12 @@ export declare const getAudioDevices: ({ video, }?: {
|
|
36
36
|
videoInputs: MediaDeviceInfo[];
|
37
37
|
}>;
|
38
38
|
export declare const isScreenShareDevice: (deviceId?: string) => boolean;
|
39
|
+
/**
|
40
|
+
* 判断是否前后置摄像头
|
41
|
+
* @param deviceId
|
42
|
+
* @returns
|
43
|
+
*/
|
44
|
+
export declare const isMobileVideoDevice: (deviceId?: string) => boolean;
|
39
45
|
/**
|
40
46
|
* Check if browser supports screen sharing
|
41
47
|
* 检查浏览器是否支持屏幕共享
|
package/dist/types/index.d.ts
CHANGED
@@ -30,6 +30,7 @@ export interface RealtimeClientConfig {
|
|
30
30
|
suppressNonStationaryNoise?: boolean /** optional, Suppress non-stationary noise, defaults to false */;
|
31
31
|
videoConfig?: VideoConfig /** optional, Video configuration */;
|
32
32
|
isAutoSubscribeAudio?: boolean /** optional, Whether to automatically subscribe to bot reply audio streams, defaults to true */;
|
33
|
+
prologueContent?: string /** optional, Prologue content */;
|
33
34
|
}
|
34
35
|
declare class RealtimeClient extends RealtimeEventHandler {
|
35
36
|
_config: RealtimeClientConfig;
|
@@ -80,6 +81,7 @@ declare class RealtimeClient extends RealtimeEventHandler {
|
|
80
81
|
* 可选,视频输入设备的设备 ID。
|
81
82
|
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
82
83
|
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
84
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
83
85
|
*/
|
84
86
|
constructor(config: RealtimeClientConfig);
|
85
87
|
/**
|
@@ -143,7 +145,12 @@ declare class RealtimeClient extends RealtimeEventHandler {
|
|
143
145
|
* zh: 设置音频输出设备
|
144
146
|
*/
|
145
147
|
setAudioOutputDevice(deviceId: string): Promise<void>;
|
146
|
-
|
148
|
+
/**
|
149
|
+
* en: Set the video input device
|
150
|
+
*
|
151
|
+
* zh: 设置视频输入设备
|
152
|
+
*/
|
153
|
+
setVideoInputDevice(deviceId: string | 'screenShare' | 'user' | 'environment'): Promise<void>;
|
147
154
|
/**
|
148
155
|
* en: Get the RTC engine instance, for detail visit https://www.volcengine.com/docs/6348/104481
|
149
156
|
*
|
package/dist/types/utils.d.ts
CHANGED
@@ -36,6 +36,12 @@ export declare const getAudioDevices: ({ video, }?: {
|
|
36
36
|
videoInputs: MediaDeviceInfo[];
|
37
37
|
}>;
|
38
38
|
export declare const isScreenShareDevice: (deviceId?: string) => boolean;
|
39
|
+
/**
|
40
|
+
* 判断是否前后置摄像头
|
41
|
+
* @param deviceId
|
42
|
+
* @returns
|
43
|
+
*/
|
44
|
+
export declare const isMobileVideoDevice: (deviceId?: string) => boolean;
|
39
45
|
/**
|
40
46
|
* Check if browser supports screen sharing
|
41
47
|
* 检查浏览器是否支持屏幕共享
|
package/dist/umd/index.js
CHANGED
@@ -96,6 +96,7 @@
|
|
96
96
|
checkDevicePermission: ()=>checkDevicePermission,
|
97
97
|
checkPermission: ()=>checkPermission,
|
98
98
|
getAudioDevices: ()=>getAudioDevices,
|
99
|
+
isMobileVideoDevice: ()=>isMobileVideoDevice,
|
99
100
|
isScreenShareDevice: ()=>isScreenShareDevice,
|
100
101
|
isScreenShareSupported: ()=>isScreenShareSupported,
|
101
102
|
sleep: ()=>sleep
|
@@ -173,6 +174,11 @@
|
|
173
174
|
};
|
174
175
|
const isScreenShareDevice = (deviceId)=>'screenShare' === deviceId;
|
175
176
|
/**
|
177
|
+
* 判断是否前后置摄像头
|
178
|
+
* @param deviceId
|
179
|
+
* @returns
|
180
|
+
*/ const isMobileVideoDevice = (deviceId)=>'user' === deviceId || 'environment' === deviceId;
|
181
|
+
/**
|
176
182
|
* Check if browser supports screen sharing
|
177
183
|
* 检查浏览器是否支持屏幕共享
|
178
184
|
*/ function isScreenShareSupported() {
|
@@ -193,6 +199,10 @@
|
|
193
199
|
* zh: 所有服务端事件
|
194
200
|
*/ EventNames["ALL_SERVER"] = "server.*";
|
195
201
|
/**
|
202
|
+
* en: Room info
|
203
|
+
* zh: 房间信息
|
204
|
+
*/ EventNames["ROOM_INFO"] = "client.room.info";
|
205
|
+
/**
|
196
206
|
* en: Client connected
|
197
207
|
* zh: 客户端连接
|
198
208
|
*/ EventNames["CONNECTED"] = "client.connected";
|
@@ -477,7 +487,7 @@
|
|
477
487
|
const devices = await getAudioDevices({
|
478
488
|
video: true
|
479
489
|
});
|
480
|
-
if (-1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
490
|
+
if (!isMobileVideoDevice(deviceId) && -1 === devices.videoInputs.findIndex((i)=>i.deviceId === deviceId)) throw new RealtimeAPIError(error_RealtimeError.DEVICE_ACCESS_ERROR, `Video input device not found: ${deviceId}`);
|
481
491
|
await this.changeVideoState(false);
|
482
492
|
if (isScreenShareDevice(deviceId)) {
|
483
493
|
if (this._streamIndex === rtc_.StreamIndex.STREAM_INDEX_MAIN) this.engine.setLocalVideoPlayer(rtc_.StreamIndex.STREAM_INDEX_MAIN);
|
@@ -658,16 +668,16 @@
|
|
658
668
|
// Step1 get token
|
659
669
|
if (getRoomInfo) roomInfo = await getRoomInfo();
|
660
670
|
else {
|
661
|
-
|
662
|
-
if (this._config.
|
663
|
-
|
671
|
+
const config = {};
|
672
|
+
if (this._config.prologueContent) config.prologue_content = this._config.prologueContent;
|
673
|
+
if (this._config.videoConfig) {
|
674
|
+
if (isScreenShareDevice(this._config.videoConfig.videoInputDeviceId)) config.video_config = {
|
664
675
|
stream_video_type: 'screen'
|
665
|
-
}
|
666
|
-
|
667
|
-
video_config: {
|
676
|
+
};
|
677
|
+
else config.video_config = {
|
668
678
|
stream_video_type: 'main'
|
669
|
-
}
|
670
|
-
}
|
679
|
+
};
|
680
|
+
}
|
671
681
|
roomInfo = await this._api.audio.rooms.create({
|
672
682
|
bot_id: botId,
|
673
683
|
conversation_id: conversationId || void 0,
|
@@ -682,6 +692,12 @@
|
|
682
692
|
this.dispatch(event_names.ERROR, error);
|
683
693
|
throw new RealtimeAPIError(error_RealtimeError.CREATE_ROOM_ERROR, error instanceof Error ? error.message : 'Unknown error', error);
|
684
694
|
}
|
695
|
+
this.dispatch(event_names.ROOM_INFO, {
|
696
|
+
roomId: roomInfo.room_id,
|
697
|
+
uid: roomInfo.uid,
|
698
|
+
token: roomInfo.token,
|
699
|
+
appId: roomInfo.app_id
|
700
|
+
});
|
685
701
|
this._isTestEnv = TEST_APP_ID === roomInfo.app_id;
|
686
702
|
// Step2 create engine
|
687
703
|
this._client = new EngineClient(roomInfo.app_id, this._config.debug, this._isTestEnv, this._isSupportVideo, this._config.videoConfig);
|
@@ -823,7 +839,11 @@
|
|
823
839
|
deviceId
|
824
840
|
});
|
825
841
|
}
|
826
|
-
|
842
|
+
/**
|
843
|
+
* en: Set the video input device
|
844
|
+
*
|
845
|
+
* zh: 设置视频输入设备
|
846
|
+
*/ async setVideoInputDevice(deviceId) {
|
827
847
|
var _this__client;
|
828
848
|
await (null === (_this__client = this._client) || void 0 === _this__client ? void 0 : _this__client.setVideoInputDevice(deviceId));
|
829
849
|
this.dispatch(event_names.VIDEO_INPUT_DEVICE_CHANGED, {
|
@@ -880,6 +900,7 @@
|
|
880
900
|
* 可选,视频输入设备的设备 ID。
|
881
901
|
* @param config.videoConfig.screenConfig - Optional, Screen share configuration if videoInputDeviceId is 'screenShare' see https://www.volcengine.com/docs/6348/104481#screenconfig for more details. |
|
882
902
|
* 可选,屏幕共享配置,如果 videoInputDeviceId 是 'screenShare',请参考 https://www.volcengine.com/docs/6348/104481#screenconfig 了解更多详情。
|
903
|
+
* @param config.prologueContent - Optional, Prologue content. | 可选,开场白内容。
|
883
904
|
*/ constructor(config){
|
884
905
|
super(config.debug), this._client = null, this.isConnected = false, this._isTestEnv = false, this._isSupportVideo = false;
|
885
906
|
this._config = config;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coze/realtime-api",
|
3
|
-
"version": "1.2.
|
3
|
+
"version": "1.2.1-beta.3",
|
4
4
|
"description": "A powerful real-time communication SDK for voice interactions with Coze AI bots | 扣子官方实时通信 SDK,用于与 Coze AI bots 进行语音交互",
|
5
5
|
"keywords": [
|
6
6
|
"coze",
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"test:cov": "vitest --coverage --run"
|
55
55
|
},
|
56
56
|
"dependencies": {
|
57
|
-
"@coze/api": "1.2.
|
57
|
+
"@coze/api": "1.2.1-beta.9",
|
58
58
|
"@volcengine/rtc": "^4.62.1"
|
59
59
|
},
|
60
60
|
"devDependencies": {
|