Table of Contents
- [Initialize Parameters] (#initialize-parameters)
- [Interface Classification] (#interface-classification)
- [Basic Interface] (#basic-interface)
- [Audio and Video Control] (#audio-and-video-control)
- [Equipment Control] (#equipment-control)
- [Input Control] (#input-control)
- [Cloud Phone Control] (#cloud-phone-control)
- [Group Control Function] (#group-control-function)
- [Media Injection] (#media-injection)
Initialize parameters
const engine = new ArmcloudEngine(params)
1. Top-level parameters
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| token | string | ✓ | Server authentication token | - |
| baseUrl | string | ✓ | SDK interface requests domain names | - |
| enableMicrophone | boolean | ✗ | Whether to enable microphones | true |
| enableCamera | boolean | ✗ | Whether to enable the camera | true |
| masterIdPrefix | string | ✗ | Prefix of the group control master device ID | "" |
2. Device information parameters
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| deviceInfo.padCode | string | ✓ | Room number/instance number, identifying the cloud phone instance | - |
| deviceInfo.userId | string | ✓ | User ID | - |
| deviceInfo.autoRecoveryTime | number | ✗ | No operation recovery time (seconds); 0 means disabled | 300 |
| deviceInfo.mediaType | number | ✗ | Media stream types (1: Audio / 2: Video / 3: Audio and Video) | 2 |
| deviceInfo.rotateType | number | ✗ | Screen orientation (0: Portrait / 1: Landscape) | Automatic judgment |
| deviceInfo.keyboard | string | ✗ | Keyboard mode ("local"/"pad") | "pad" |
| deviceInfo.saveCloudClipboard | boolean | ✗ | Whether cloud phone shear panel callback is enabled | true |
| deviceInfo.allowLocalIMEInCloud | boolean | ✗ | Can you use the local input method when using a cloud keyboard? | false |
| deviceInfo.disableContextMenu | boolean | ✗ | Whether to disable the right-click menu | false |
| deviceInfo.videoDeviceId | string | ✗ | Specify the camera device ID | Automatic selection |
| deviceInfo.audioDeviceId | string | ✗ | Specify the microphone device ID | Automatic selection |
| deviceInfo.disableLocalIME | boolean | ✗ | Disable the local keyboard | false |
3. Video streaming parameters
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| deviceInfo.videoStream.resolution | number | ✗ | Video resolution | 12 |
| deviceInfo.videoStream.frameRate | number | ✗ | Video frame rate | 2 |
| deviceInfo.videoStream.bitrate | number | ✗ | Video bitrate | 3 |
Video Quality Presets
| Quality grade | Resolution ID | Frame rate ID | Bitrate ID |
|---|---|---|---|
| Smooth | 9 | 8 | 15 |
| Clear definition | 10 | 8 | 15 |
| High definition | 12 | 8 | 1 |
| Ultra clear | 15 | 1 | 3 |
Note: For detailed configuration parameters, please refer to the [Set Resolution, Bitrate, Frame Rate] (#set-resolution-bitrate-and-frame-rate) section
Interface Classification
Basic Interfaces
- isSupported - Detects whether the browser supports RTC services
- start - Join the room
- stop - Leave the room
Audio and Video Control
- setStreamConfig - Sets video parameters
- muted/unmuted - Audio control
- increaseVolume/decreaseVolume - Volume control
- resumeAllSubscribedStream - Resumes the stream
- pauseAllSubscribedStream - Pauses streaming
Equipment Control
- setMicrophone - Microphone control
- setCamera - Camera control
- setVideoDeviceId - Specifies the camera
- setAudioDeviceId - Specifies the microphone
- setMonitorOperation - Whether operation monitoring is enabled
Input control
- setKeyboardStyle - Toggles input method types
- sendCommand - Send key commands
- sendInputString - Send text to the input box
- sendInputClipper - Send text to the clipboard
- saveCloudClipboard - Controls clipboard callbacks
- triggerClickEvent - Simulates click
- triggerPointerEvent - Simulates touch
- triggerKeyboardShortcut - Commonly used shortcuts
Cloud Mobile Control
- setGPS - Set GPS location
- sendShake - Send a shake command
- setAutoRecycleTime/getAutoRecycleTime - Manages the recycle time
- setPhoneRotation - Sets horizontal and vertical screens
- executeAdbCommand - Executes the ADB command
- saveScreenShotToLocal/saveScreenShotToRemote - Screenshot function
- setScreenResolution - Sets and restores phone resolution and DPI
Group Control Function
- toggleGroupControlSync - Whether to stop syncing
- joinGroupRoom - Join the group control room
- kickItOutRoom - Kick out of the group control room
Media injection
- injectVideoStream - Video injection control
- startMediaStream/stopMediaStream - Camera/microphone injection
- getInjectStreamStatus - Retrieves injection status
Basic Interfaces
Browser compatibility testing
Check whether your current browser supports RTC service with static methods.
Method Definition
ArmcloudEngine.isSupported()
Return Value
Promise<boolean> - Returns whether your current browser supports RTC services
Sample Codes
const isSupported = ArmcloudEngine.isSupported();
if (!isSupported) {
console.warn("Currently, browsers do not support RTC services");
return false;
}
Join the room
Connect to the cloud phone and start remote control.
Method Definition
engine.start(isGroupControl, pads)
*Specifications
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| isGroupControl | boolean | ✗ | Whether group control mode is enabled | false |
| pads | string[] | ✗ | The array of instance numbers that need to be group-controlled | [] |
Sample Codes
// Normal mode connection
engine.start(false, []);
// Group control mode connection
engine.start(true, ["ACXXXX", "ACXXXX"]);
Leaving the room
Disconnect, release resources.
Method Definition
engine.stop()
Return Value
Promise<void> - Returns the result of stopping the operation
Sample Codes
try {
await engine.stop();
console.log("Disconnected");
} catch (error) {
console.error("Disconnection failure:", error);
}
Important Note: The
stop()method will destroy the engine and the DOM nodes created. To switch cloud phones, call thestop()before eachnew ArmcloudEngine().
Audio and Video Control
Set Camera Video Stream Resolution
Added in v1.5.5
Set the release resolution of the camera video stream to meet different network environments and picture quality requirements.
Method Definition
engine.setVideoEncoder(
width: number,
height: number
)
Parameter Description
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| width | number | ✓ | Recommended value: 1920 |
| height | number | ✓ | Recommended value: 1080 |
Set resolution, bitrate, and frame rate
Adjust video streaming parameters to meet different network environments and picture quality requirements.
Method Definition
engine.setStreamConfig(definitionConfig: {
definitionId: number; // Resolution ID
framerateId: number; // Frame rate ID
bitrateId: number; // Bitrate ID
},forwardOff: boolean)
Parameter Description
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| definitionConfig | Object | ✓ | Video stream configuration objects |
| definitionConfig.definitionId | number | ✓ | Resolution ID, controls video clarity |
| definitionConfig.framerateId | number | ✓ | Frame rate ID, controls video smoothness |
| definitionConfig.bitrateId | number | ✓ | Bitrate ID, controls the amount of video data |
| forwardOff | boolead | ✗ | Whether to disable forwarding to the group control room and enable it only takes effect; default is true |
Resolution Parameter Value (definitionId)
| ID | Resolution | Applicable scenarios |
|---|---|---|
| 7 | 144×256 | Extremely low bandwidth environment |
| 8 | 216×384 | Low bandwidth environment |
| 9 | 288×512 | Smooth mode |
| 10 | 360×640 | Standard definition mode |
| 11 | 480×848 | Enhanced standard definition |
| 12 | 540×960 | HD mode |
| 13 | 600×1024 | Enhanced HD |
| 14 | 480×1280 | Widescreen mode |
| 15 | 720×1280 | Ultra HD mode |
| 16 | 720×1920 | Wide screen ultra-clear display |
| 17 | 1080×1920 | Full HD |
| 18 | 1440×1920 | 2K quality |
| 19 | 1600×2560 | Ultra HD |
| 20 | 2880×1080 | Extremely wide field of view |
FrameRate Parameter Value (framerateId)
| ID | Frame rate | Applicable scenarios |
|---|---|---|
| 1 | 20fps | Standard smoothness |
| 2 | 25fps | Enhance smoothness |
| 3 | 30fps | High smoothness |
| 4 | 60fps | Extremely smooth, suitable for fast-moving scenarios |
| 5 | 1fps | Minimum network usage, static scenarios |
| 6 | 5fps | Low network usage |
| 7 | 10fps | Basic smoothness |
| 8 | 15fps | Normal smoothness |
| 9 | 2fps | Ultra-low network usage |
**BitrateId]
| ID | Bit rate | Applicable scenarios |
|---|---|---|
| 1 | 1Mbps | HD mode base bitrate |
| 2 | 1.5Mbps | HD mode enhances bitrate |
| 3 | 2Mbps | Ultra HD mode base bitrate |
| 4 | 2.5Mbps | Ultra HD mode enhances bitrate |
| 5 | 3Mbps | Ultra HD mode with advanced bitrate |
| 6 | 3.5Mbps | Full HD basic bitrate |
| 7 | 4Mbps | Full HD standard bitrate |
| 8 | 5Mbps | Full HD enhanced bitrate |
| 9 | 6Mbps | 2K base bitrate |
| 10 | 8Mbps | 2K standard bitrate |
| 11 | 10Mbps | 2K enhanced bitrate |
| 12 | 12Mbps | Ultra HD bitrate |
| 13 | 200kbps | Extremely low bandwidth environment |
| 14 | 400kbps | Low bandwidth environment |
| 15 | 600kbps | Smooth mode base bitrate |
Common Image Quality Presets
| Usage scenarios | Recommended configuration |
|---|---|
| Saves data usage | { definitionId: 9, framerateId: 8, bitrateId: 15 } |
| Balanced mode | { definitionId: 10, framerateId: 8, bitrateId: 15 } |
| HD mode | { definitionId: 12, framerateId: 8, bitrateId: 1 } |
| Ultra HD mode | { definitionId: 15, framerateId: 1, bitrateId: 3 } |
| 2K quality | { definitionId: 18, framerateId: 3, bitrateId: 10 } |
Sample Codes
// Set to HD mode
engine.setStreamConfig({
definitionId: 12, // 540×960
framerateId: 2, // 25fps
bitrateId: 3 // 2Mbps
});
// Set smooth mode (low bandwidth environment)
engine.setStreamConfig({
definitionId: 9, // 288×512
framerateId: 8, // 15fps
bitrateId: 15 // 600kbps
});
// Set Ultra HD mode (high-bandwidth environment)
engine.setStreamConfig({
definitionId: 15, // 720×1280
framerateId: 3, // 30fps
bitrateId: 5 // 3Mbps
});
Resuming Streaming
Restoring audio and video streaming.
Method Definition
engine.resumeAllSubscribedStream(mediaType)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| mediaType | number | ✓ | Media types: 1 (audio), 2 (video), 3 (audio and video) |
Sample Codes
// Restoring audio and video streaming
engine.resumeAllSubscribedStream(3);
// Only restore audio
engine.resumeAllSubscribedStream(1);
// Only the video was restored
engine.resumeAllSubscribedStream(2);
Pausing Streaming
Pausing audio and video streaming to save bandwidth.
Method Definition
engine.pauseAllSubscribedStream(mediaType)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| mediaType | number | ✓ | Media types: 1 (audio), 2 (video), 3 (audio and video) |
Sample Codes
// Pause audio and video streaming
engine.pauseAllSubscribedStream(3);
// Only pause the audio
engine.pauseAllSubscribedStream(1);
// Only pause video streaming
engine.pauseAllSubscribedStream(2);
Mute and Unmute
Control the audio output of cloud phones.
Method Definition
// Turn on mute
engine.muted()
// Turn off silent
engine.unmuted()
Return Value
None
Sample Codes
// Turn on mute
engine.muted();
// Turn off silent
engine.unmuted();
Volume control
Adjust the volume volume of the cloud phone.
Method Definition
// Turn up the volume
engine.increaseVolume()
// Turn down the volume
engine.decreaseVolume()
Return Value
None
Sample Codes
// Turn up the volume
engine.increaseVolume();
// Turn down the volume
engine.decreaseVolume();
Equipment Control
Microphone control
Control whether the local microphone transmits audio to the cloud phone.
Method Definition
engine.setMicrophone(enable)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| enable | boolean | ✓ | true means the microphone is enabled, false means the microphone is disabled |
Sample Codes
// Turn on the microphone
engine.setMicrophone(true);
// Microphones are prohibited
engine.setMicrophone(false);
Camera control
Control whether the local camera transmits video to the cloud phone.
Method Definition
engine.setCamera(enable)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| enable | boolean | ✓ | true means camera on, false means camera disable |
Sample Codes
// Enable the camera
engine.setCamera(true);
// Disable the camera
engine.setCamera(false);
Designated Equipment
Specify the camera or microphone device to use.
Method Definition
// Specify the camera
engine.setVideoDeviceId(deviceId)
// Specify the microphone
engine.setAudioDeviceId(deviceId)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| deviceId | string | ✓ | Device ID, empty string indicates automatic device selection |
Sample Codes
// Specify the camera
engine.setVideoDeviceId('ab484e060c5f1186004457c5be97e874e976983ebf66e1227e4e925523fc4f11');
// Specify the microphone
engine.setAudioDeviceId('ab484e060c5f1186004457c5be97e874e976983ebf66e1227e4e925523fc4f11');
// Automatic device selection
engine.setVideoDeviceId('');
engine.setAudioDeviceId('');
Whether to enable operation monitoring
Whether operation monitoring is enabled.
Method Definition
engine.setMonitorOperation(enable:boolean, forwardOff:boolean)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| enable | boolean | ✓ | true means operation monitoring is enabled, false means operation monitoring is disabled |
| forwardOff | boolean | ✗ | Whether to disable forwarding to the group control room and enable it only takes effect; default is true |
Sample Codes
// Enable operation monitoring
engine.setMonitorOperation(true);
// Disable operation monitoring
engine.setMonitorOperation(false);
Input control
Keyboard input control
Switch the input method type.
Method Definition
engine.setKeyboardStyle(keyboard)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| keyboard | string | ✓ | Keyboard modes: "local" (local input method), "pad" (cloud phone virtual input method) |
Sample Codes
// Use local input methods
engine.setKeyboardStyle('local');
// Use a cloud-machine virtual input method
engine.setKeyboardStyle('pad');
Button control
Send system key commands.
Method Definition
engine.sendCommand(command:string, forwardOff: boolean)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| command | string | ✓ | Key commands: "back", "home", "menu", [see android.view.KeyEvent official documentation] (https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ENTER) |
| forwardOff | boolean | ✗ | Whether to disable forwarding to the group control room? Enabling group control takes effect; default is false |
Sample Codes
// Send the return key
engine.sendCommand("back");
// Send the Home button
engine.sendCommand("home");
// Send menu key
engine.sendCommand("menu");
// Send and press Enter
engine.sendCommand("66");
Text input
Send text to the input box on the cloud phone.
Method Definition
engine.sendInputString(text, forwardOff)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| text | string | ✓ | The text content to be entered |
| forwardOff | boolean | ✗ | Whether to disable forwarding to the group control room? Enabling group control takes effect; default is false |
Sample Codes
// Enter text in the focus input box
engine.sendInputString('hello world');
Note: This operation only sends the text to the input box and will not update the cloud phone clipboard content.
Clipboard Control
Manage content on the clipboard of cloud phones.
Method Definition
// Send text to the cloud phone clipboard
engine.sendInputClipper(text, forwardOff)
// Control whether to receive callbacks from the cloud phone clipboard
engine.saveCloudClipboard(flag)
*Specifications
| Method | Parameter name | Type | Required | Explanation |
|---|---|---|---|---|
| sendInputClipper | text | string | ✓ | Text content to be sent to the clipboard |
| sendInputClipper | forwardOff | boolean | ✗ | Whether to disable forwarding to the group control room? Enabling group control takes effect; default is false |
| saveCloudClipboard | flag | boolean | ✓ | true means receiving clipboard callbacks; false means not accepting |
Sample Codes
// To send text to the cloud server clipboard, you need to long-press and paste it in the cloud server input box to use it
engine.sendInputClipper('hello world');
// Enable the cloud phone clipboard content callback
engine.saveCloudClipboard(true);
// Disable the cloud server clipboard content callback
engine.saveCloudClipboard(false);
Touch Simulation
Simulating touch and click events.
Method Definition
// Simulated click
engine.triggerClickEvent(options: {
x: number; // Click the X coordinate
y: number; // Click the y-coordinate of the point
width: number; // Container width
height: number; // Container height
})
// Simulated touch
engine.triggerPointerEvent(
action: number, // Types of touch actions
options: {
x: number; // Touch the x coordinate
y: number; // Touch the y-coordinate of the touch
width: number; // Container width
height: number; // Container height
}
)
Parameter Description
| Method | Parameter name | Type | Required | Explanation |
|---|---|---|---|---|
| triggerClickEvent | options | Object | ✓ | Click Event Configuration Object |
| triggerClickEvent | options.x | number | ✓ | Click the horizontal coordinate position |
| triggerClickEvent | options.y | number | ✓ | The vertical coordinate position of the click |
| triggerClickEvent | options.width | number | ✓ | The width of the video container |
| triggerClickEvent | options.height | number | ✓ | The height of the video container |
| triggerPointerEvent | action | number | ✓ | Touch action types: 0 (press), 1 (lift), 2 (moving) |
| triggerPointerEvent | options | Object | ✓ | Touch event configuration objects |
| triggerPointerEvent | options.x | number | ✓ | Touch the horizontal coordinate position |
| triggerPointerEvent | options.y | number | ✓ | Touch the vertical coordinate position |
| triggerPointerEvent | options.width | number | ✓ | The width of the video container |
| triggerPointerEvent | options.height | number | ✓ | The height of the video container |
Coordinate Calculation Explanation: The coordinate value (x, y) is the position relative to the video container, calculated by the formula:
- Actual X coordinates = x / width * actual video width
- Actual Y coordinate = y / height * actual video height
Sample Codes
// Simulate click
engine.triggerClickEvent({
x: 430, // Click the X coordinate of the position
y: 1383, // Click the Y coordinate of the position
width: 871, // Container width
height: 1550 // Container height
});
// Simulated sliding operation
// 1. Press
engine.triggerPointerEvent(0, {
x: 92, // Starting position X coordinate
y: 1325, // Starting position at Y coordinates
width: 871, // Container width
height: 1550 // Container height
});
// 2. The process of moving
engine.triggerPointerEvent(2, {
x: 92, // Center position X coordinate (horizontal unchanged)
y: 1326, // Y coordinate at the middle position (slight change)
width: 871, // Container width
height: 1550 // Container height
});
// 3. Lift
setTimeout(() => {
engine.triggerPointerEvent(1, {
x: 92, // End position X coordinate
y: 1330, // End position Y coordinate (vertical shifted)
width: 871, // Container width
height: 1550 // Container height
});
}, 1);
// Simulates long-press operation
// 1. Press
engine.triggerPointerEvent(0, {
x: 300,
y: 500,
width: 871,
height: 1550
});
// 2. Lift after delay (simulates long press effect)
setTimeout(() => {
engine.triggerPointerEvent(1, {
x: 300,
y: 500,
width: 871,
height: 1550
});
}, 800); // Press and hold for 800 milliseconds
Common Shortcuts
Simulates shortcut keys within the cloud phone using keyCode.
Method Definition
engine.triggerKeyboardShortcut(metaState, keyCode)
Parameter Description
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| metaState | number | ✓ | Modifying key status, [see the official android.view.KeyEvent documentation] (https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ENTER) |
| keyCode | number | ✓ | The actual key pressed [see the official android.view.KeyEvent documentation] (https://developer.android.com/reference/android/view/KeyEvent#KEYCODE_ENTER) |
Sample Codes
// Select the cloud phone text box content = ctrl + a
engine.triggerKeyboardShortcut(8192, 29)
// Copy the selected text box content = ctrl + c. After copying, the clipboard callback will be triggered
engine.triggerKeyboardShortcut(8192,31)
Cloud Phone Control
Location Simulation
Set the GPS location information for the cloud phone.
Method Definition
engine.setGPS(longitude, latitude)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| longitude | number | ✓ | Longitude value |
| latitude | number | ✓ | Latitude values |
Sample Codes
// Longitude 113, latitude 28
engine.setGPS(113, 28);
Equipment Control
Send device-specific commands.
Method Definition
engine.sendShake(time)
*Specifications
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| time | number | ✗ | Shake duration (milliseconds) | 1500 |
Sample Codes
// The default duration is 1.5 seconds
engine.sendShake();
// Lasts for 2 seconds
engine.sendShake(2000);
Note: Prolonged time may result in multiple screenshots.
Recycling Control
Manage the automatic recovery time for cloud phones without any operations.
Method Definition
// Set the recycling time
engine.setAutoRecycleTime(second)
// Get the payback time
engine.getAutoRecycleTime()
*Specifications
| Method | Parameter name | Type | Required | Explanation |
|---|---|---|---|---|
| setAutoRecycleTime | second | number | ✓ | Automatic recycling time (seconds): 0~7200; 0 means automatic recycling is disabled |
Return Value
| Method | Return type | Explanation |
|---|---|---|
| getAutoRecycleTime | Promise<number> | Currently set auto-recycle time (seconds) |
Sample Codes
// Set 5 minutes without operation for recycling
engine.setAutoRecycleTime(300);
// Disable automatic recycling
engine.setAutoRecycleTime(0);
// Get the current recycling time
engine.getAutoRecycleTime().then(time => {
console.log(`Current inactivity recycling time: ${time} seconds`);
});
Screen orientation
Set the screen orientation of the cloud phone.
Method Definition
engine.setPhoneRotation(type)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| type | number | ✓ | Screen orientation: 0 (portrait), 1 (landscape) |
Sample Codes
// Set up vertical screen
engine.setPhoneRotation(0);
// Set up landscape mode
engine.setPhoneRotation(1);
Advanced Controls
Execute the ADB command.
Method Definition
engine.executeAdbCommand(command, forwardOff)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| command | string | ✓ | The ADB command to execute |
| forwardOff | boolean | ✗ | Whether to disable forwarding to the group control room and enable it only takes effect; default is true |
Sample Codes
// List the root directory file
engine.executeAdbCommand('cd /;ls');
Screenshot Function
Capture screenshots from cloud phones.
Method Definition
// Screenshot and save to your local location
engine.saveScreenShotToLocal()
// Screenshot and save to the cloud phone
engine.saveScreenShotToRemote()
Return Value
| Method | Return type | Explanation |
|---|---|---|
| saveScreenShotToLocal | Promise<ImageData> | Screenshot of image data |
| saveScreenShotToRemote | void | No return value |
Sample Codes
// Screenshot and save to your local location
engine.saveScreenShotToLocal().then(imageData => {
// Create canvas elements
const canvas = document.createElement("canvas");
canvas.width = imageData.width;
canvas.height = imageData.height;
const ctx = canvas.getContext("2d");
// Draw image data onto the canvas
ctx.putImageData(imageData, 0, 0);
// Save the image
const link = document.createElement("a");
link.href = canvas.toDataURL();
link.download = "screenshot.png";
link.click();
});
// Screenshots saved to the cloud phone photo album
engine.saveScreenShotToRemote();
Screen resolution and DPI
Modify and restore screen resolution and DPI
Method Definition
engine.setScreenResolution(options, forwardOff)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| options.width | number | ✗ | Width |
| options.height | number | ✗ | Height |
| options.dpi | number | ✗ | DPI |
| options.type | string | ✓ | Type: 1. updateDensity (update resolution and DPI) 2. resetDensity (restores default resolution and DPI; other options parameters are invalid in this case) |
| forwardOff | boolean | ✗ | Whether to disable forwarding to the group control room and enable it only takes effect; default is true |
Sample Codes
// Modify resolution and DPI
engine.setScreenResolution({
width: 720,
height: 1280,
dpi: 360,
type: 'updateDensity'
});
// Restores default resolution and DPI
engine.setScreenResolution({
type: 'resetDensity'
});
Group Control Function
Manage group control operations for multiple cloud phones.
Whether to stop syncing
Method Definition
engine.toggleGroupControlSync(flag)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| flag | boolean | ✓ | Whether to stop syncing |
Sample Codes
// Enable synchronization
engine.toggleGroupControlSync(true)
// Stop syncing
engine.toggleGroupControlSync(false)
Group Control Joins Room
Method Definition
engine.joinGroupRoom(pads)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| pads | string[] | ✓ | The array of instance numbers that need to be group-controlled |
Sample Codes
// Add multiple instances to the group control room
engine.joinGroupRoom(['ACXXXX', 'ACXXXX']);
Kick out of the group control room
Method Definition
engine.kickItOutRoom(pads)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| pads | string[] | ✓ | The instance number array that needs to be kicked out of the group control |
Sample Codes
// Kick out the specified instance
engine.kickItOutRoom(['ACXXXX']);
Media injection
Video Injection
Import video into the cloud phone camera.
Method Definition
engine.injectVideoStream(
type: "startVideoInjection" | "stopVideoInjection",
options?: {
fileUrl: string; // Video file path
isLoop?: boolean; // Whether to play on loop
fileName?: string; // Video file name
}
)
Parameter Description
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| type | string | ✓ | Operation type: "startVideoInjection", "stopVideoInjection" | - |
| options | Object | Required when type is "startVideoInjection" | Inject configuration items | - |
| options.fileUrl | string | ✓ | Video file paths, supporting internal paths or external URL addresses for cloud phones | - |
| options.isLoop | boolean | ✗ | Whether to loop the video | true |
| options.fileName | string | fileUrl is required when the URL is used | Video file name | - |
Technical Requirements
| Project | Requirements |
|---|---|
| Supported video formats | H.264 and H.265 codes |
| Video resolution | The width and height must be a multiple of 2 |
Sample Codes
// Insert videos from URLs
engine.injectVideoStream('startVideoInjection', {
fileUrl: 'http://example.com/video.mp4',
isLoop: true,
fileName: 'video.mp4' // URL address required
});
// Inject video from internal storage of the cloud phone
engine.injectVideoStream('startVideoInjection', {
fileUrl: '/sdcard/Downloads/video.mp4',
isLoop: true
});
// Insert videos from the internal storage of the cloud phone (single playback)
engine.injectVideoStream('startVideoInjection', {
fileUrl: '/sdcard/Downloads/video.mp4',
isLoop: false
});
// Stop video injection
engine.injectVideoStream('stopVideoInjection');
Camera microphone injection
Inject local cameras and microphones into cloud phones.
Method Definition
// Launch injection
engine.startMediaStream(mediaType)
// Stop the injection
engine.stopMediaStream(mediaType)
*Specifications
| Parameter name | Type | Required | Explanation |
|---|---|---|---|
| mediaType | number | ✓ | Media types: 1 (microphone), 2 (camera), 3 (camera and microphone) |
Sample Codes
// Activate the camera and microphone injection
engine.startMediaStream(3);
// Only start microphone injection
engine.startMediaStream(1);
// Only activate the camera injection
engine.startMediaStream(2);
// Stop the camera injection
engine.stopMediaStream(2);
// Stop the microphone injection
engine.stopMediaStream(1);
// Stop all injections
engine.stopMediaStream(3);
Injection status query
Obtain media injection status.
Method Definition
engine.getInjectStreamStatus(type, timeout)
*Specifications
| Parameter name | Type | Required | Explanation | Default values |
|---|---|---|---|---|
| type | string | ✓ | Query types: "video" (video injection), "camera", "audio" (microphone) | - |
| timeout | number | ✗ | Timeout time (milliseconds): 0 means no timeout is set | 0 |
Return Value
Returns a Promise, which resolves as an object containing the following properties:
| Attribute name | Type | Explanation |
|---|---|---|
| type | string | Injection types: "video", "camera", "audio" |
| status | string | Injection status: "live" (streaming), "offline," "unknown," "timeout" |
| path | string | The push path exists only when the type is "video" |
Sample Codes
// Check the video injection status
engine.getInjectStreamStatus("video").then(res => {
console.log(`Type: ${res.type}`); // Injection type
console.log(`Status: ${res.status}`); // Injection status
if (res.path) {
console.log(`Path: ${res.path}`); // This field is only present when injecting video
}
});
// Check the camera injection status, 5-second timeout
engine.getInjectStreamStatus("camera", 5000).then(res => {
console.log(`Type: ${res.type}`); // Injection type
console.log(`Status: ${res.status}`); // Injection status
});