larksr_websdk 3.3.113 → 3.3.114
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/doc/en/config.md +228 -228
- package/dist/doc/en/dev.md +83 -83
- package/dist/doc/en/event_codes.md +286 -286
- package/dist/doc/en/events.md +229 -229
- package/dist/doc/en/functions.md +603 -603
- package/dist/doc/en/index.md +115 -115
- package/dist/doc/en/member_variables.md +403 -403
- package/dist/doc/en/multi_media_3_2_401.md +83 -83
- package/dist/doc/en/sdkid_encryption.md +40 -40
- package/dist/doc/en/update.md +462 -462
- package/dist/doc/zh_CN/update.md +579 -579
- package/dist/larksr-web-sdk.min.js +1 -1
- package/dist/types/api.d.ts +1 -1
- package/dist/types/event/event_base.d.ts +1 -1
- package/dist/types/larksr.d.ts +1 -1
- package/dist/types/operation/keymap.d.ts +1 -1
- package/dist/types/protobuf/cloudlark.d.ts +3 -10160
- package/dist/types/screen_state.d.ts +1 -1
- package/package.json +72 -72
- package/types/api.d.ts +1 -1
- package/types/event/event_base.d.ts +1 -1
- package/types/larksr.d.ts +1 -1
- package/types/operation/keymap.d.ts +1 -1
- package/types/protobuf/cloudlark.d.ts +3 -10160
- package/types/screen_state.d.ts +1 -1
- package/dist/types/lark/custom.d.ts +0 -7
- package/dist/types/lark/webcodecs.generated.d.ts +0 -417
- package/dist/types/utils/ios-inner-height.d.ts +0 -4
- package/types/lark/custom.d.ts +0 -7
- package/types/lark/webcodecs.generated.d.ts +0 -417
- package/types/utils/ios-inner-height.d.ts +0 -4
|
@@ -1,403 +1,403 @@
|
|
|
1
|
-
# LarkSR Object Member Variables
|
|
2
|
-
|
|
3
|
-
LarkSR object member variables. Note that variables starting with an underscore are internal private variables or read-only member variables and are not recommended for direct modification or use.
|
|
4
|
-
|
|
5
|
-
> In the following code, `larksr` is an instance of the created LarkSR object. The creation process is omitted.
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
let larksr;
|
|
9
|
-
|
|
10
|
-
// ... create code.
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## Video Component
|
|
14
|
-
|
|
15
|
-
1. `videoComponent` Video Component
|
|
16
|
-
|
|
17
|
-
```javascript
|
|
18
|
-
// Get the <video /> video element being played
|
|
19
|
-
larksr.videoComponent.getVideo();
|
|
20
|
-
// Play the video, async method throws an exception if playback fails
|
|
21
|
-
larksr.videoComponent.playVideo();
|
|
22
|
-
// Stop video playback
|
|
23
|
-
larksr.videoComponent.stopVideo();
|
|
24
|
-
// Play video sound, unmute playback
|
|
25
|
-
larksr.videoComponent.sountPlayout();
|
|
26
|
-
// Capture a frame, return base64, and throw a screenshot success event
|
|
27
|
-
larksr.videoComponent.captrueFrame(data);
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
2. videoElement HTML video video element itself
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
larksr.videoElement;
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
3. Control Display Elements
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
// Whether to show touch points on mobile
|
|
40
|
-
larksr.isEnableTouchPoint = false;
|
|
41
|
-
// Whether to show bottom text during loading screen
|
|
42
|
-
larksr.isEnableLoadingStateBar = false;
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
```javascript
|
|
46
|
-
// Set zoom mode
|
|
47
|
-
larksr.scaleMode = ScaleMode.CONTAIN_APP;
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
4. Virtual Mouse and Touch Points
|
|
51
|
-
|
|
52
|
-
```javascript
|
|
53
|
-
/**
|
|
54
|
-
* Current position of the virtual mouse, relative to the overall container
|
|
55
|
-
*/
|
|
56
|
-
larksr.virtualCursorPosition
|
|
57
|
-
/**
|
|
58
|
-
* Current position of the virtual mouse, internal zoom container, same as the actual display virtual mouse CSS style
|
|
59
|
-
*/
|
|
60
|
-
larksr.virtualCursorPositionRaw
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Example:
|
|
64
|
-
|
|
65
|
-
The following example code uses React to demonstrate clicking a button to synchronize the position of an outer element and the virtual mouse.
|
|
66
|
-
|
|
67
|
-
```javascript
|
|
68
|
-
// ....
|
|
69
|
-
// Omitted React creation code
|
|
70
|
-
export default class App extends React.Component {
|
|
71
|
-
private state: any = {
|
|
72
|
-
pointPosition: {
|
|
73
|
-
x: 0,
|
|
74
|
-
y: 0,
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
// ....
|
|
78
|
-
// Omitted larksr creation process and other code
|
|
79
|
-
render() {
|
|
80
|
-
return (
|
|
81
|
-
<div>
|
|
82
|
-
// ...
|
|
83
|
-
// Omitted other elements
|
|
84
|
-
<div style={{
|
|
85
|
-
zIndex: 1000,
|
|
86
|
-
position: 'absolute',
|
|
87
|
-
left: this.state.pointPosition.x,
|
|
88
|
-
top: this.state.pointPosition.y,
|
|
89
|
-
backgroundColor: "red",
|
|
90
|
-
width: 50,
|
|
91
|
-
height: 50,
|
|
92
|
-
borderRadius: "50%"
|
|
93
|
-
}}>
|
|
94
|
-
</div>
|
|
95
|
-
<button style={{pointerEvents: "all"}}
|
|
96
|
-
onClick={()=>{
|
|
97
|
-
// Get the position of the virtual mouse
|
|
98
|
-
console.log("touch point", this.larksr.virtualCursorPosition);
|
|
99
|
-
// Synchronize the position of the virtual mouse
|
|
100
|
-
this.setState({
|
|
101
|
-
pointPosition: this.larksr.virtualCursorPosition,
|
|
102
|
-
})
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
touchPoint
|
|
106
|
-
</button>
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
## Configuration Parameters
|
|
114
|
-
|
|
115
|
-
```javascript
|
|
116
|
-
// `config` ILarkSRConfig object passed in IAppliParams
|
|
117
|
-
larksr.config;
|
|
118
|
-
// `params` IAppliParams object passed in the constructor
|
|
119
|
-
larksr.params;
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## User Mode
|
|
123
|
-
|
|
124
|
-
```javascript
|
|
125
|
-
// `playerModeType` Current player mode;
|
|
126
|
-
larksr.playerModeType;
|
|
127
|
-
// `userType` Current user type;
|
|
128
|
-
larksr.userType;
|
|
129
|
-
// Whether it is currently in interactive mode, the default interactive mode is operable
|
|
130
|
-
larksr.isInteractiveMode;
|
|
131
|
-
// Whether it is observer mode
|
|
132
|
-
larksr.isObMode;
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
## Current App State
|
|
136
|
-
|
|
137
|
-
```javascript
|
|
138
|
-
larksr.appState;
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Specific state values are as follows:
|
|
142
|
-
|
|
143
|
-
```javascript
|
|
144
|
-
export enum APP_STATE {
|
|
145
|
-
BEFORE_CREATE = 0,
|
|
146
|
-
INITED,
|
|
147
|
-
WEBSOCKET_CHANNEL_OPEN,
|
|
148
|
-
LOGIN_SUCCESS,
|
|
149
|
-
RTC_CONNECTED,
|
|
150
|
-
MEDIA_LOADED,
|
|
151
|
-
MEDIA_PLAED,
|
|
152
|
-
RTC_RETRY,
|
|
153
|
-
APP_RETRY,
|
|
154
|
-
BEFORE_DESTORY,
|
|
155
|
-
WEBSOCKET_CLOSED,
|
|
156
|
-
RTC_CLOSED,
|
|
157
|
-
DESTROYED,
|
|
158
|
-
}
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
You can listen to the APP_STATE changes through the event APPSTATE_CHANGE = 'appstatechange'.
|
|
162
|
-
|
|
163
|
-
```javascript
|
|
164
|
-
// create code
|
|
165
|
-
...
|
|
166
|
-
|
|
167
|
-
// Listen to the connection success event
|
|
168
|
-
larksr.on('appstatechange', function(e) {
|
|
169
|
-
console.log("appstatechange", e);
|
|
170
|
-
});
|
|
171
|
-
```
|
|
172
|
-
|
|
173
|
-
## Whether the Cloud Screen is Ready
|
|
174
|
-
|
|
175
|
-
```javascript
|
|
176
|
-
// Whether the cloud screen is ready, input events can only be sent after it is ready
|
|
177
|
-
larksr.remoteScreenReady
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## Current Screen State
|
|
181
|
-
|
|
182
|
-
```javascript
|
|
183
|
-
// Notify viewport change or need to recalculate display properties
|
|
184
|
-
larksr.screenState.resize();
|
|
185
|
-
// Current size of the cloud app
|
|
186
|
-
larksr.screenState.appSize;
|
|
187
|
-
// Current mouse state of the cloud app
|
|
188
|
-
larksr.screenState.appMouseMode;
|
|
189
|
-
// Current size of the rendering container
|
|
190
|
-
larksr.screenState.viewPort;
|
|
191
|
-
// Force landscape mode
|
|
192
|
-
larksr.screenState.screenOrientation;
|
|
193
|
-
// Zoom mode
|
|
194
|
-
larksr.screenState.scaleMode;
|
|
195
|
-
// Whether it is in full screen mode
|
|
196
|
-
larksr.screenState.isFullScreen;
|
|
197
|
-
// Whether the mouse state is locked
|
|
198
|
-
larksr.screenState.isLockMouse;
|
|
199
|
-
// Mouse style of the cloud app
|
|
200
|
-
larksr.screenState.cursorStyle;
|
|
201
|
-
// Initialize mouse mode
|
|
202
|
-
larksr.screenState.initCursorMode;
|
|
203
|
-
// Whether it is mobile mode
|
|
204
|
-
larksr.screenState.isMobile;
|
|
205
|
-
// Whether to render the local mouse
|
|
206
|
-
larksr.screenState.isLocalRenderMouse;
|
|
207
|
-
// Whether to lock the mouse
|
|
208
|
-
larksr.screenState.isLockMosue;
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
Listen to the state changes of screenState, the event code is 0. It is called after screenState.resize() is triggered internally or externally by the SDK.
|
|
212
|
-
|
|
213
|
-
```javascript
|
|
214
|
-
larksr.screenState.on(0, () => {
|
|
215
|
-
console.log("screen state resize", larksr.screenState.screenOrientation);
|
|
216
|
-
});
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
## Operation Class Instances
|
|
220
|
-
|
|
221
|
-
```javascript
|
|
222
|
-
// Start listening, automatically starts by default
|
|
223
|
-
larksr.op.startListening();
|
|
224
|
-
// Stop listening to input events.
|
|
225
|
-
larksr.op.stopListenling();
|
|
226
|
-
// Enable or disable mouse input events
|
|
227
|
-
larksr.op.setMouseEnable(enable: boolean);
|
|
228
|
-
// Enable or disable keyboard input events
|
|
229
|
-
larksr.op.setKeyboardEnable(enable: boolean);
|
|
230
|
-
// Enable or disable gamepad input events
|
|
231
|
-
larksr.op.setGamepadEnable(enable: boolean);
|
|
232
|
-
// Enable or disable touch screen input events
|
|
233
|
-
larksr.op.setTouchEnable(enable: boolean);
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Keyboard Handler in Operation Class
|
|
237
|
-
|
|
238
|
-
```javascript
|
|
239
|
-
// Set the default interception of keyboard events to prevent the default behavior of the browser.
|
|
240
|
-
// The keys in preventKeys will be intercepted, if the array is empty, all will be intercepted
|
|
241
|
-
// Default interception F1 F5 F12
|
|
242
|
-
larksr.op.keyboardHandler.preventKeys = [["F1", "F5", "F12"]];
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
### Gesture Handler in Operation Class
|
|
246
|
-
|
|
247
|
-
gestureHandler handles the process of converting mobile touch events to mouse events.
|
|
248
|
-
|
|
249
|
-
#### Adjust Touch Event Trigger Parameters
|
|
250
|
-
|
|
251
|
-
```javascript
|
|
252
|
-
// The speed of the mouse relative movement provided when the touch event is converted to a mouse event.
|
|
253
|
-
// That is, rx = (pxNew-pxOld) * relativeMouseMoveSpeed
|
|
254
|
-
// ry = (pyNew-pyOld) * relativeMouseMoveSpeed
|
|
255
|
-
// May affect the effect of cloud applications that use relative movement (rawInput) judgment
|
|
256
|
-
larksr.op.gestureHandler.relativeMouseMoveSpeed = 2;
|
|
257
|
-
// The judgment range for simulating clicks when touch events are converted to mouse events.
|
|
258
|
-
// Actual mouse events generally do not move when clicked, but touch operations will almost certainly trigger move events
|
|
259
|
-
// If you want to simulate click events on a PC, such as single or double clicks, no mouse move should be inserted between mouse down and up
|
|
260
|
-
// When a move event is triggered, a move event is sent only if it exceeds this judgment range.
|
|
261
|
-
// Note that modifying this value may cause single or double click failures on cloud applications, but it generally has little impact if the cloud application does not include similar operations
|
|
262
|
-
larksr.op.gestureHandler.tapLimitRadius = 20;
|
|
263
|
-
// Attempts to send a single click down event within this time range, modifying this value may affect the success rate of triggering single click events
|
|
264
|
-
larksr.op.gestureHandler.tapLimitTimeout = 100;
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
#### Intercept Touch Event Callback
|
|
268
|
-
|
|
269
|
-
You can set the specific correspondence between touch events and mouse events by intercepting the touch event callback.
|
|
270
|
-
|
|
271
|
-
> Set the callback function through larksr.op.gestureHandler.gestureCallback The GESTURE_TYPE in the example below is the gesture event type exported by the SDK. If the SDK is introduced in amd mode, all exported types are under the larksr_websdk global object. If the SDK is introduced in other ways, such as importing import { GESTURE_TYPE } from 'larksr_websdk' The following example code omits the larksr creation process and other code
|
|
272
|
-
|
|
273
|
-
```javascript
|
|
274
|
-
// The event parameter has the following fields
|
|
275
|
-
// event : {
|
|
276
|
-
// type: GESTURE_TYPE; Gesture event type
|
|
277
|
-
// x: number; Converted to cloud coordinate x
|
|
278
|
-
// y: number; Converted to cloud coordinate y
|
|
279
|
-
// rx: number; Converted to cloud coordinate rx
|
|
280
|
-
// ry: number; Converted to cloud coordinate ry
|
|
281
|
-
// edge: boolean; Whether it reaches the touch edge
|
|
282
|
-
// rawEvent: any; Touch event not converted to cloud coordinates
|
|
283
|
-
// }
|
|
284
|
-
//
|
|
285
|
-
larksr.op.gestureHandler.gestureCallback = (event) => {
|
|
286
|
-
console.log(event);
|
|
287
|
-
const p = event;
|
|
288
|
-
switch (event.type) {
|
|
289
|
-
// Single touch starts moving the mouse to the current position
|
|
290
|
-
case GESTURE_TYPE.SINGLE_FINGER_TOUCH_START:
|
|
291
|
-
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
292
|
-
break;
|
|
293
|
-
// Single finger tap -> left mouse click
|
|
294
|
-
case GESTURE_TYPE.SINGLE_FINGER_TAP:
|
|
295
|
-
larksr.mouseTap(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
296
|
-
break;
|
|
297
|
-
// Single finger tap down -> move mouse, press mouse
|
|
298
|
-
case GESTURE_TYPE.SINGLE_FINGER_TAP_DOWN:
|
|
299
|
-
// move mouse first
|
|
300
|
-
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
301
|
-
// sync tap down
|
|
302
|
-
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
303
|
-
break;
|
|
304
|
-
// Single finger tap up -> move mouse, release mouse
|
|
305
|
-
case GESTURE_TYPE.SINGLE_FINGER_TAP_UP:
|
|
306
|
-
// move mouse first
|
|
307
|
-
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
308
|
-
// sync tap down
|
|
309
|
-
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
310
|
-
break;
|
|
311
|
-
// Single finger swipe -> move mouse
|
|
312
|
-
case GESTURE_TYPE.SINGLE_FINGER_SWIPE:
|
|
313
|
-
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
314
|
-
break;
|
|
315
|
-
// Single finger swipe start -> left mouse button down
|
|
316
|
-
case GESTURE_TYPE.SINGLE_FINGER_SWIPE_START:
|
|
317
|
-
// sync tap down
|
|
318
|
-
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
319
|
-
break;
|
|
320
|
-
// Single finger swipe end -> left mouse button up
|
|
321
|
-
case GESTURE_TYPE.SINGLE_FINGER_SWIPE_END:
|
|
322
|
-
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
323
|
-
break;
|
|
324
|
-
// Double finger tap -> right mouse click
|
|
325
|
-
case GESTURE_TYPE.DOUBLE_FINGER_TAP:
|
|
326
|
-
larksr.mouseTap(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
327
|
-
break;
|
|
328
|
-
// Double finger tap down -> move mouse
|
|
329
|
-
case GESTURE_TYPE.DOUBLE_FINGER_TAP_DOWN:
|
|
330
|
-
// move mouse first
|
|
331
|
-
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
332
|
-
// sync tap down
|
|
333
|
-
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
334
|
-
break;
|
|
335
|
-
case GESTURE_TYPE.DOUBLE_FINGER_TAP_UP:
|
|
336
|
-
// move mouse first
|
|
337
|
-
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
338
|
-
// sync tap up
|
|
339
|
-
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
340
|
-
break;
|
|
341
|
-
// Double finger swipe -> scroll wheel
|
|
342
|
-
case GESTURE_TYPE.DOUBLE_FINGER_SWIPE:
|
|
343
|
-
// move mouse mid
|
|
344
|
-
// this.$emitMouseWheel(p.x, p.y, e.motion.y);
|
|
345
|
-
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
346
|
-
break;
|
|
347
|
-
case GESTURE_TYPE.DOUBLE_FINGER_EXPAND:
|
|
348
|
-
// Windows message deltaY up is +120 down is -120
|
|
349
|
-
// Double finger expand swipe outwards
|
|
350
|
-
// Scroll wheel down
|
|
351
|
-
// move mouse mid
|
|
352
|
-
larksr.mouseWheel(p.x, p.y, 120);
|
|
353
|
-
break;
|
|
354
|
-
case GESTURE_TYPE.DOUBLE_FINGER_SHRINK:
|
|
355
|
-
// Windows message deltaY up is +120 down is -120
|
|
356
|
-
// Double finger swipe inwards
|
|
357
|
-
// Scroll wheel up
|
|
358
|
-
larksr.mouseWheel(p.x, p.y, -120);
|
|
359
|
-
break;
|
|
360
|
-
case GESTURE_TYPE.DOUBLE_FINGER_SWIPE_END:
|
|
361
|
-
// sync tap up
|
|
362
|
-
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
363
|
-
break;
|
|
364
|
-
// Triple finger tap -> middle mouse click
|
|
365
|
-
case GESTURE_TYPE.TRIPLE_FINGER_TAP:
|
|
366
|
-
larksr.mouseTap(p.x, p.y, CloudLark.MouseKey.MIDDLE);
|
|
367
|
-
break;
|
|
368
|
-
// Triple finger swipe -> move mouse
|
|
369
|
-
case GESTURE_TYPE.TRIPLE_FINGER_SWIPE:
|
|
370
|
-
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
371
|
-
break;
|
|
372
|
-
// Triple finger swipe start -> middle mouse button down
|
|
373
|
-
case GESTURE_TYPE.TRIPLE_FINGER_SWIPE_START:
|
|
374
|
-
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
375
|
-
//
|
|
376
|
-
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.MIDDLE);
|
|
377
|
-
break;
|
|
378
|
-
// Triple finger swipe end -> middle mouse button up
|
|
379
|
-
case GESTURE_TYPE.TRIPLE_FINGER_SWIPE_END:
|
|
380
|
-
// sync tap up
|
|
381
|
-
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.MIDDLE);
|
|
382
|
-
break;
|
|
383
|
-
// All fingers up
|
|
384
|
-
case GESTURE_TYPE.RELEASE:
|
|
385
|
-
break;
|
|
386
|
-
default:
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
## Full Screen and Lock Screen
|
|
393
|
-
|
|
394
|
-
```javascript
|
|
395
|
-
// Enter full screen mode
|
|
396
|
-
larksr.fullScreen.launchFullScreen();
|
|
397
|
-
// Exit full screen mode
|
|
398
|
-
larksr.fullScreen.exitFullscreen();
|
|
399
|
-
// Lock the mouse
|
|
400
|
-
larksr.lockPointer.lockPointer();
|
|
401
|
-
// Release the mouse
|
|
402
|
-
larksr.lockPointer.exitPointerLock();
|
|
403
|
-
```
|
|
1
|
+
# LarkSR Object Member Variables
|
|
2
|
+
|
|
3
|
+
LarkSR object member variables. Note that variables starting with an underscore are internal private variables or read-only member variables and are not recommended for direct modification or use.
|
|
4
|
+
|
|
5
|
+
> In the following code, `larksr` is an instance of the created LarkSR object. The creation process is omitted.
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
let larksr;
|
|
9
|
+
|
|
10
|
+
// ... create code.
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Video Component
|
|
14
|
+
|
|
15
|
+
1. `videoComponent` Video Component
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
// Get the <video /> video element being played
|
|
19
|
+
larksr.videoComponent.getVideo();
|
|
20
|
+
// Play the video, async method throws an exception if playback fails
|
|
21
|
+
larksr.videoComponent.playVideo();
|
|
22
|
+
// Stop video playback
|
|
23
|
+
larksr.videoComponent.stopVideo();
|
|
24
|
+
// Play video sound, unmute playback
|
|
25
|
+
larksr.videoComponent.sountPlayout();
|
|
26
|
+
// Capture a frame, return base64, and throw a screenshot success event
|
|
27
|
+
larksr.videoComponent.captrueFrame(data);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
2. videoElement HTML video video element itself
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
larksr.videoElement;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
3. Control Display Elements
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
// Whether to show touch points on mobile
|
|
40
|
+
larksr.isEnableTouchPoint = false;
|
|
41
|
+
// Whether to show bottom text during loading screen
|
|
42
|
+
larksr.isEnableLoadingStateBar = false;
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
// Set zoom mode
|
|
47
|
+
larksr.scaleMode = ScaleMode.CONTAIN_APP;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. Virtual Mouse and Touch Points
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
/**
|
|
54
|
+
* Current position of the virtual mouse, relative to the overall container
|
|
55
|
+
*/
|
|
56
|
+
larksr.virtualCursorPosition
|
|
57
|
+
/**
|
|
58
|
+
* Current position of the virtual mouse, internal zoom container, same as the actual display virtual mouse CSS style
|
|
59
|
+
*/
|
|
60
|
+
larksr.virtualCursorPositionRaw
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
|
|
65
|
+
The following example code uses React to demonstrate clicking a button to synchronize the position of an outer element and the virtual mouse.
|
|
66
|
+
|
|
67
|
+
```javascript
|
|
68
|
+
// ....
|
|
69
|
+
// Omitted React creation code
|
|
70
|
+
export default class App extends React.Component {
|
|
71
|
+
private state: any = {
|
|
72
|
+
pointPosition: {
|
|
73
|
+
x: 0,
|
|
74
|
+
y: 0,
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// ....
|
|
78
|
+
// Omitted larksr creation process and other code
|
|
79
|
+
render() {
|
|
80
|
+
return (
|
|
81
|
+
<div>
|
|
82
|
+
// ...
|
|
83
|
+
// Omitted other elements
|
|
84
|
+
<div style={{
|
|
85
|
+
zIndex: 1000,
|
|
86
|
+
position: 'absolute',
|
|
87
|
+
left: this.state.pointPosition.x,
|
|
88
|
+
top: this.state.pointPosition.y,
|
|
89
|
+
backgroundColor: "red",
|
|
90
|
+
width: 50,
|
|
91
|
+
height: 50,
|
|
92
|
+
borderRadius: "50%"
|
|
93
|
+
}}>
|
|
94
|
+
</div>
|
|
95
|
+
<button style={{pointerEvents: "all"}}
|
|
96
|
+
onClick={()=>{
|
|
97
|
+
// Get the position of the virtual mouse
|
|
98
|
+
console.log("touch point", this.larksr.virtualCursorPosition);
|
|
99
|
+
// Synchronize the position of the virtual mouse
|
|
100
|
+
this.setState({
|
|
101
|
+
pointPosition: this.larksr.virtualCursorPosition,
|
|
102
|
+
})
|
|
103
|
+
}}
|
|
104
|
+
>
|
|
105
|
+
touchPoint
|
|
106
|
+
</button>
|
|
107
|
+
</div>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Configuration Parameters
|
|
114
|
+
|
|
115
|
+
```javascript
|
|
116
|
+
// `config` ILarkSRConfig object passed in IAppliParams
|
|
117
|
+
larksr.config;
|
|
118
|
+
// `params` IAppliParams object passed in the constructor
|
|
119
|
+
larksr.params;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## User Mode
|
|
123
|
+
|
|
124
|
+
```javascript
|
|
125
|
+
// `playerModeType` Current player mode;
|
|
126
|
+
larksr.playerModeType;
|
|
127
|
+
// `userType` Current user type;
|
|
128
|
+
larksr.userType;
|
|
129
|
+
// Whether it is currently in interactive mode, the default interactive mode is operable
|
|
130
|
+
larksr.isInteractiveMode;
|
|
131
|
+
// Whether it is observer mode
|
|
132
|
+
larksr.isObMode;
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Current App State
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
larksr.appState;
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Specific state values are as follows:
|
|
142
|
+
|
|
143
|
+
```javascript
|
|
144
|
+
export enum APP_STATE {
|
|
145
|
+
BEFORE_CREATE = 0,
|
|
146
|
+
INITED,
|
|
147
|
+
WEBSOCKET_CHANNEL_OPEN,
|
|
148
|
+
LOGIN_SUCCESS,
|
|
149
|
+
RTC_CONNECTED,
|
|
150
|
+
MEDIA_LOADED,
|
|
151
|
+
MEDIA_PLAED,
|
|
152
|
+
RTC_RETRY,
|
|
153
|
+
APP_RETRY,
|
|
154
|
+
BEFORE_DESTORY,
|
|
155
|
+
WEBSOCKET_CLOSED,
|
|
156
|
+
RTC_CLOSED,
|
|
157
|
+
DESTROYED,
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
You can listen to the APP_STATE changes through the event APPSTATE_CHANGE = 'appstatechange'.
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
// create code
|
|
165
|
+
...
|
|
166
|
+
|
|
167
|
+
// Listen to the connection success event
|
|
168
|
+
larksr.on('appstatechange', function(e) {
|
|
169
|
+
console.log("appstatechange", e);
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Whether the Cloud Screen is Ready
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
// Whether the cloud screen is ready, input events can only be sent after it is ready
|
|
177
|
+
larksr.remoteScreenReady
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Current Screen State
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
// Notify viewport change or need to recalculate display properties
|
|
184
|
+
larksr.screenState.resize();
|
|
185
|
+
// Current size of the cloud app
|
|
186
|
+
larksr.screenState.appSize;
|
|
187
|
+
// Current mouse state of the cloud app
|
|
188
|
+
larksr.screenState.appMouseMode;
|
|
189
|
+
// Current size of the rendering container
|
|
190
|
+
larksr.screenState.viewPort;
|
|
191
|
+
// Force landscape mode
|
|
192
|
+
larksr.screenState.screenOrientation;
|
|
193
|
+
// Zoom mode
|
|
194
|
+
larksr.screenState.scaleMode;
|
|
195
|
+
// Whether it is in full screen mode
|
|
196
|
+
larksr.screenState.isFullScreen;
|
|
197
|
+
// Whether the mouse state is locked
|
|
198
|
+
larksr.screenState.isLockMouse;
|
|
199
|
+
// Mouse style of the cloud app
|
|
200
|
+
larksr.screenState.cursorStyle;
|
|
201
|
+
// Initialize mouse mode
|
|
202
|
+
larksr.screenState.initCursorMode;
|
|
203
|
+
// Whether it is mobile mode
|
|
204
|
+
larksr.screenState.isMobile;
|
|
205
|
+
// Whether to render the local mouse
|
|
206
|
+
larksr.screenState.isLocalRenderMouse;
|
|
207
|
+
// Whether to lock the mouse
|
|
208
|
+
larksr.screenState.isLockMosue;
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Listen to the state changes of screenState, the event code is 0. It is called after screenState.resize() is triggered internally or externally by the SDK.
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
larksr.screenState.on(0, () => {
|
|
215
|
+
console.log("screen state resize", larksr.screenState.screenOrientation);
|
|
216
|
+
});
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Operation Class Instances
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
// Start listening, automatically starts by default
|
|
223
|
+
larksr.op.startListening();
|
|
224
|
+
// Stop listening to input events.
|
|
225
|
+
larksr.op.stopListenling();
|
|
226
|
+
// Enable or disable mouse input events
|
|
227
|
+
larksr.op.setMouseEnable(enable: boolean);
|
|
228
|
+
// Enable or disable keyboard input events
|
|
229
|
+
larksr.op.setKeyboardEnable(enable: boolean);
|
|
230
|
+
// Enable or disable gamepad input events
|
|
231
|
+
larksr.op.setGamepadEnable(enable: boolean);
|
|
232
|
+
// Enable or disable touch screen input events
|
|
233
|
+
larksr.op.setTouchEnable(enable: boolean);
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Keyboard Handler in Operation Class
|
|
237
|
+
|
|
238
|
+
```javascript
|
|
239
|
+
// Set the default interception of keyboard events to prevent the default behavior of the browser.
|
|
240
|
+
// The keys in preventKeys will be intercepted, if the array is empty, all will be intercepted
|
|
241
|
+
// Default interception F1 F5 F12
|
|
242
|
+
larksr.op.keyboardHandler.preventKeys = [["F1", "F5", "F12"]];
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Gesture Handler in Operation Class
|
|
246
|
+
|
|
247
|
+
gestureHandler handles the process of converting mobile touch events to mouse events.
|
|
248
|
+
|
|
249
|
+
#### Adjust Touch Event Trigger Parameters
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
// The speed of the mouse relative movement provided when the touch event is converted to a mouse event.
|
|
253
|
+
// That is, rx = (pxNew-pxOld) * relativeMouseMoveSpeed
|
|
254
|
+
// ry = (pyNew-pyOld) * relativeMouseMoveSpeed
|
|
255
|
+
// May affect the effect of cloud applications that use relative movement (rawInput) judgment
|
|
256
|
+
larksr.op.gestureHandler.relativeMouseMoveSpeed = 2;
|
|
257
|
+
// The judgment range for simulating clicks when touch events are converted to mouse events.
|
|
258
|
+
// Actual mouse events generally do not move when clicked, but touch operations will almost certainly trigger move events
|
|
259
|
+
// If you want to simulate click events on a PC, such as single or double clicks, no mouse move should be inserted between mouse down and up
|
|
260
|
+
// When a move event is triggered, a move event is sent only if it exceeds this judgment range.
|
|
261
|
+
// Note that modifying this value may cause single or double click failures on cloud applications, but it generally has little impact if the cloud application does not include similar operations
|
|
262
|
+
larksr.op.gestureHandler.tapLimitRadius = 20;
|
|
263
|
+
// Attempts to send a single click down event within this time range, modifying this value may affect the success rate of triggering single click events
|
|
264
|
+
larksr.op.gestureHandler.tapLimitTimeout = 100;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### Intercept Touch Event Callback
|
|
268
|
+
|
|
269
|
+
You can set the specific correspondence between touch events and mouse events by intercepting the touch event callback.
|
|
270
|
+
|
|
271
|
+
> Set the callback function through larksr.op.gestureHandler.gestureCallback The GESTURE_TYPE in the example below is the gesture event type exported by the SDK. If the SDK is introduced in amd mode, all exported types are under the larksr_websdk global object. If the SDK is introduced in other ways, such as importing import { GESTURE_TYPE } from 'larksr_websdk' The following example code omits the larksr creation process and other code
|
|
272
|
+
|
|
273
|
+
```javascript
|
|
274
|
+
// The event parameter has the following fields
|
|
275
|
+
// event : {
|
|
276
|
+
// type: GESTURE_TYPE; Gesture event type
|
|
277
|
+
// x: number; Converted to cloud coordinate x
|
|
278
|
+
// y: number; Converted to cloud coordinate y
|
|
279
|
+
// rx: number; Converted to cloud coordinate rx
|
|
280
|
+
// ry: number; Converted to cloud coordinate ry
|
|
281
|
+
// edge: boolean; Whether it reaches the touch edge
|
|
282
|
+
// rawEvent: any; Touch event not converted to cloud coordinates
|
|
283
|
+
// }
|
|
284
|
+
//
|
|
285
|
+
larksr.op.gestureHandler.gestureCallback = (event) => {
|
|
286
|
+
console.log(event);
|
|
287
|
+
const p = event;
|
|
288
|
+
switch (event.type) {
|
|
289
|
+
// Single touch starts moving the mouse to the current position
|
|
290
|
+
case GESTURE_TYPE.SINGLE_FINGER_TOUCH_START:
|
|
291
|
+
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
292
|
+
break;
|
|
293
|
+
// Single finger tap -> left mouse click
|
|
294
|
+
case GESTURE_TYPE.SINGLE_FINGER_TAP:
|
|
295
|
+
larksr.mouseTap(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
296
|
+
break;
|
|
297
|
+
// Single finger tap down -> move mouse, press mouse
|
|
298
|
+
case GESTURE_TYPE.SINGLE_FINGER_TAP_DOWN:
|
|
299
|
+
// move mouse first
|
|
300
|
+
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
301
|
+
// sync tap down
|
|
302
|
+
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
303
|
+
break;
|
|
304
|
+
// Single finger tap up -> move mouse, release mouse
|
|
305
|
+
case GESTURE_TYPE.SINGLE_FINGER_TAP_UP:
|
|
306
|
+
// move mouse first
|
|
307
|
+
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
308
|
+
// sync tap down
|
|
309
|
+
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
310
|
+
break;
|
|
311
|
+
// Single finger swipe -> move mouse
|
|
312
|
+
case GESTURE_TYPE.SINGLE_FINGER_SWIPE:
|
|
313
|
+
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
314
|
+
break;
|
|
315
|
+
// Single finger swipe start -> left mouse button down
|
|
316
|
+
case GESTURE_TYPE.SINGLE_FINGER_SWIPE_START:
|
|
317
|
+
// sync tap down
|
|
318
|
+
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
319
|
+
break;
|
|
320
|
+
// Single finger swipe end -> left mouse button up
|
|
321
|
+
case GESTURE_TYPE.SINGLE_FINGER_SWIPE_END:
|
|
322
|
+
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.LEFT);
|
|
323
|
+
break;
|
|
324
|
+
// Double finger tap -> right mouse click
|
|
325
|
+
case GESTURE_TYPE.DOUBLE_FINGER_TAP:
|
|
326
|
+
larksr.mouseTap(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
327
|
+
break;
|
|
328
|
+
// Double finger tap down -> move mouse
|
|
329
|
+
case GESTURE_TYPE.DOUBLE_FINGER_TAP_DOWN:
|
|
330
|
+
// move mouse first
|
|
331
|
+
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
332
|
+
// sync tap down
|
|
333
|
+
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
334
|
+
break;
|
|
335
|
+
case GESTURE_TYPE.DOUBLE_FINGER_TAP_UP:
|
|
336
|
+
// move mouse first
|
|
337
|
+
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
338
|
+
// sync tap up
|
|
339
|
+
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
340
|
+
break;
|
|
341
|
+
// Double finger swipe -> scroll wheel
|
|
342
|
+
case GESTURE_TYPE.DOUBLE_FINGER_SWIPE:
|
|
343
|
+
// move mouse mid
|
|
344
|
+
// this.$emitMouseWheel(p.x, p.y, e.motion.y);
|
|
345
|
+
larksr.moseMove(p.x, p.y, p.rx, p.ry);
|
|
346
|
+
break;
|
|
347
|
+
case GESTURE_TYPE.DOUBLE_FINGER_EXPAND:
|
|
348
|
+
// Windows message deltaY up is +120 down is -120
|
|
349
|
+
// Double finger expand swipe outwards
|
|
350
|
+
// Scroll wheel down
|
|
351
|
+
// move mouse mid
|
|
352
|
+
larksr.mouseWheel(p.x, p.y, 120);
|
|
353
|
+
break;
|
|
354
|
+
case GESTURE_TYPE.DOUBLE_FINGER_SHRINK:
|
|
355
|
+
// Windows message deltaY up is +120 down is -120
|
|
356
|
+
// Double finger swipe inwards
|
|
357
|
+
// Scroll wheel up
|
|
358
|
+
larksr.mouseWheel(p.x, p.y, -120);
|
|
359
|
+
break;
|
|
360
|
+
case GESTURE_TYPE.DOUBLE_FINGER_SWIPE_END:
|
|
361
|
+
// sync tap up
|
|
362
|
+
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.RIGHT);
|
|
363
|
+
break;
|
|
364
|
+
// Triple finger tap -> middle mouse click
|
|
365
|
+
case GESTURE_TYPE.TRIPLE_FINGER_TAP:
|
|
366
|
+
larksr.mouseTap(p.x, p.y, CloudLark.MouseKey.MIDDLE);
|
|
367
|
+
break;
|
|
368
|
+
// Triple finger swipe -> move mouse
|
|
369
|
+
case GESTURE_TYPE.TRIPLE_FINGER_SWIPE:
|
|
370
|
+
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
371
|
+
break;
|
|
372
|
+
// Triple finger swipe start -> middle mouse button down
|
|
373
|
+
case GESTURE_TYPE.TRIPLE_FINGER_SWIPE_START:
|
|
374
|
+
larksr.mouseMove(p.x, p.y, p.rx, p.ry);
|
|
375
|
+
//
|
|
376
|
+
larksr.mouseDown(p.x, p.y, CloudLark.MouseKey.MIDDLE);
|
|
377
|
+
break;
|
|
378
|
+
// Triple finger swipe end -> middle mouse button up
|
|
379
|
+
case GESTURE_TYPE.TRIPLE_FINGER_SWIPE_END:
|
|
380
|
+
// sync tap up
|
|
381
|
+
larksr.mouseUp(p.x, p.y, CloudLark.MouseKey.MIDDLE);
|
|
382
|
+
break;
|
|
383
|
+
// All fingers up
|
|
384
|
+
case GESTURE_TYPE.RELEASE:
|
|
385
|
+
break;
|
|
386
|
+
default:
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
## Full Screen and Lock Screen
|
|
393
|
+
|
|
394
|
+
```javascript
|
|
395
|
+
// Enter full screen mode
|
|
396
|
+
larksr.fullScreen.launchFullScreen();
|
|
397
|
+
// Exit full screen mode
|
|
398
|
+
larksr.fullScreen.exitFullscreen();
|
|
399
|
+
// Lock the mouse
|
|
400
|
+
larksr.lockPointer.lockPointer();
|
|
401
|
+
// Release the mouse
|
|
402
|
+
larksr.lockPointer.exitPointerLock();
|
|
403
|
+
```
|