ue-softphone-sdk 5.0.2 → 5.0.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/README.md CHANGED
@@ -9,5 +9,100 @@
9
9
  > 4.0.24 不论监听与否都会连接通话socket
10
10
  > 4.0.27 修复退出登录时socket关闭错误,导致用户再次初始化状态异常
11
11
  > 4.0.30 登录增加passwordPk参数
12
- > 4.0.31 muteRing方法关闭铃声后,也不要挂断提示音
13
- > 5.0.0 新测试demo升级
12
+
13
+ > 5.0.3
14
+ ## WebRTC麦克风控制
15
+
16
+ ### 1、开启或关闭麦克风
17
+
18
+ 该方法仅支持 `WEBRTC` 登录方式,并且需要在通话已建立、本地麦克风音轨存在时调用。其他登录方式调用时会返回失败提示。
19
+
20
+ `ue.webrtc.setMicrophoneEnabled(Object object)`
21
+
22
+ 参数:
23
+
24
+ | 属性 | 类型 | 可选值 | 默认值 | 必填 | 说明 |
25
+ | --- | --- | --- | --- | --- | --- |
26
+ | success | function | - | - | 否 | 调用成功回调 |
27
+ | fail | function | - | - | 否 | 调用失败回调 |
28
+ | enabled | boolean | - | - | 是 | 是否开启麦克风 |
29
+
30
+ object.enabled 的合法值
31
+
32
+ | 值 | 说明 |
33
+ | --- | --- |
34
+ | true | 开启麦克风 |
35
+ | false | 关闭麦克风 |
36
+
37
+ 调用成功返回:
38
+
39
+ ```js
40
+ {
41
+ success: true,
42
+ message: "setMicrophoneEnabled success",
43
+ enabled: true
44
+ }
45
+ ```
46
+
47
+ 非 WEBRTC 登录方式调用失败返回:
48
+
49
+ ```js
50
+ {
51
+ success: false,
52
+ message: "当前登录方式不支持麦克风控制,请切换为 WEBRTC 登录方式!"
53
+ }
54
+ ```
55
+
56
+ 示例:
57
+
58
+ ```js
59
+ // 开启麦克风
60
+ ue.webrtc.setMicrophoneEnabled({
61
+ enabled: true,
62
+ success: function (res) {
63
+ console.log(res, "开启麦克风成功");
64
+ },
65
+ fail: function (error) {
66
+ console.log(error, "开启麦克风失败");
67
+ }
68
+ });
69
+
70
+ // 关闭麦克风
71
+ ue.webrtc.setMicrophoneEnabled({
72
+ enabled: false,
73
+ success: function (res) {
74
+ console.log(res, "关闭麦克风成功");
75
+ },
76
+ fail: function (error) {
77
+ console.log(error, "关闭麦克风失败");
78
+ }
79
+ });
80
+ ```
81
+
82
+ ### 2、查询麦克风状态
83
+
84
+ 该方法用于查询当前 WEBRTC 本地麦克风音轨是否开启。需要在 `WEBRTC` 登录方式下,并且本地麦克风音轨已存在时调用。
85
+
86
+ `ue.webrtc.isMicrophoneEnabled()`
87
+
88
+ 参数:
89
+
90
+
91
+
92
+ 返回值:
93
+
94
+ | 类型 | 说明 |
95
+ | --- | --- |
96
+ | boolean | `true` 表示麦克风已开启,`false` 表示麦克风已关闭或当前没有可用的本地麦克风音轨 |
97
+
98
+ 示例:
99
+
100
+ ```js
101
+ const enabled = ue.webrtc.isMicrophoneEnabled();
102
+
103
+ if (enabled) {
104
+ console.log("麦克风已开启");
105
+ } else {
106
+ console.log("麦克风已关闭或暂无可用麦克风音轨");
107
+ }
108
+ ```
@@ -45,6 +45,8 @@ export default class ueSoftphone {
45
45
  disconnect(): Promise<void>;
46
46
  isConnected(): boolean;
47
47
  sendDTMF(tone: string): void;
48
+ setMicrophoneEnabled(input: boolean | import("./sdk/types").SetMicrophoneEnabledParams): boolean;
49
+ isMicrophoneEnabled(): boolean;
48
50
  };
49
51
  get call(): {
50
52
  callout(params: import("./sdk/types").DialoutParams): Promise<any>;
@@ -74,6 +76,8 @@ export default class ueSoftphone {
74
76
  disconnect(): Promise<void>;
75
77
  isConnected(): boolean;
76
78
  sendDTMF(tone: string): void;
79
+ setMicrophoneEnabled(input: boolean | import("./sdk/types").SetMicrophoneEnabledParams): boolean;
80
+ isMicrophoneEnabled(): boolean;
77
81
  };
78
82
  destroy(callbacks?: DestroyCallbacks): void;
79
83
  }
@@ -40,4 +40,6 @@ export declare const bindWebrtcFacade: (store: any, initWebrtcEvent: (extras: an
40
40
  disconnect(): Promise<void>;
41
41
  isConnected(): boolean;
42
42
  sendDTMF(tone: string): void;
43
+ setMicrophoneEnabled(input: boolean | import("./types").SetMicrophoneEnabledParams): boolean;
44
+ isMicrophoneEnabled(): boolean;
43
45
  };
@@ -85,6 +85,9 @@ export interface HoldOrUnHoldParams extends TypeTarget, SuccessFailCallbacks {
85
85
  export interface MuteOrUnMuteParams extends TypeTarget, SuccessFailCallbacks {
86
86
  direction: String;
87
87
  }
88
+ export interface SetMicrophoneEnabledParams extends SuccessFailCallbacks {
89
+ enabled: boolean;
90
+ }
88
91
  export interface TransferParams extends SuccessFailCallbacks {
89
92
  type: String;
90
93
  number: String;
@@ -1,14 +1,19 @@
1
+ import type { SetMicrophoneEnabledParams } from "./types";
1
2
  interface WebPhoneApiDependencies {
2
3
  getWebPhone: () => any;
3
4
  getAgentExtras: () => any;
5
+ getInitOptions: () => any;
4
6
  initWebrtcEvent: (extras: any) => Promise<void>;
5
7
  onAccept: () => void;
6
8
  }
9
+ type SetMicrophoneEnabledInput = boolean | SetMicrophoneEnabledParams;
7
10
  export declare const createWebPhoneApi: (deps: WebPhoneApiDependencies) => {
8
11
  accept(): void;
9
12
  connect(): Promise<void>;
10
13
  disconnect(): Promise<void>;
11
14
  isConnected(): boolean;
12
15
  sendDTMF(tone: string): void;
16
+ setMicrophoneEnabled(input: SetMicrophoneEnabledInput): boolean;
17
+ isMicrophoneEnabled(): boolean;
13
18
  };
14
19
  export {};
@@ -2,5 +2,8 @@ import { UeWebrtc as SharedWebrtc } from "ue-webrtc";
2
2
  export type WebrtcOptions = ConstructorParameters<typeof SharedWebrtc>[0];
3
3
  export default class UeWebrtc extends SharedWebrtc {
4
4
  constructor(options: WebrtcOptions);
5
+ private getLocalAudioTrack;
6
+ setMicrophoneEnabled(enabled: boolean): boolean;
7
+ isMicrophoneEnabled(): boolean;
5
8
  ueUnregisterWebrtc(): Promise<boolean | void>;
6
9
  }