Table of Contents
- Initialization Parameters
- API Categories
- Basic APIs
- Audio/Video Control
- Device Control
- Input Control
- Cloud Phone Control
- Multi-Control Features
- Media Injection
Initialization Parameters
const engine = new ArmcloudEngine(params)
1. Top-Level Parameters
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| token | string | ✓ | Server authentication token | - |
| baseUrl | string | ✓ | SDK API base domain | - |
| enableMicrophone | boolean | ✗ | Enable microphone | true |
| enableCamera | boolean | ✗ | Enable camera | true |
| masterIdPrefix | string | ✗ | Prefix for multi-control master device ID | "" |
2. Device Information Parameters
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| deviceInfo.padCode | string | ✓ | Room ID / Instance ID identifying the cloud phone | - |
| deviceInfo.userId | string | ✓ | User ID | - |
| deviceInfo.autoRecoveryTime | number | ✗ | Idle recycle time (seconds), 0 to disable | 300 |
| deviceInfo.mediaType | number | ✗ | Media stream type (1: audio, 2: video, 3: both) | 2 |
| deviceInfo.rotateType | number | ✗ | Screen orientation (0: portrait, 1: landscape) | Auto-detect |
| deviceInfo.keyboard | string | ✗ | Keyboard mode ("local"/"pad") | "pad" |
| deviceInfo.saveCloudClipboard | boolean | ✗ | Enable cloud phone clipboard callback | true |
| deviceInfo.allowLocalIMEInCloud | boolean | ✗ | Allow local IME when using cloud keyboard | false |
| deviceInfo.disableContextMenu | boolean | ✗ | Disable context menu | false |
| deviceInfo.videoDeviceId | string | ✗ | Specify camera device ID | Auto-select |
| deviceInfo.audioDeviceId | string | ✗ | Specify microphone device ID | Auto-select |
| deviceInfo.disableLocalIME | boolean | ✗ | Disable local keyboard | false |
3. Video Stream Parameters
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| 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 Level | Resolution ID | Frame Rate ID | Bitrate ID |
|---|---|---|---|
| Smooth | 9 | 8 | 15 |
| SD | 10 | 8 | 15 |
| HD | 12 | 8 | 1 |
| Ultra HD | 15 | 1 | 3 |
Note: For detailed configuration parameters, see the Set Resolution, Bitrate, Frame Rate section.
API Categories
Basic APIs
- isSupported - Check if browser supports RTC
- start - Join room
- stop - Leave room
Audio/Video Control
- setStreamConfig - Set video parameters
- muted/unmuted - Audio mute control
- increaseVolume/decreaseVolume - Volume control
- resumeAllSubscribedStream - Resume streaming
- pauseAllSubscribedStream - Pause streaming
Device Control
- setMicrophone - Microphone control
- setCamera - Camera control
- setVideoDeviceId - Specify camera
- setAudioDeviceId - Specify microphone
- setMonitorOperation - Enable operation monitoring
Input Control
- setKeyboardStyle - Switch keyboard mode
- sendCommand - Send key command
- sendInputString - Send text to input field
- sendInputClipper - Send text to clipboard
- saveCloudClipboard - Control clipboard callback
- triggerClickEvent - Simulate click
- triggerPointerEvent - Simulate touch
- triggerKeyboardShortcut - Common shortcuts
Cloud Phone Control
- setGPS - Set GPS location
- sendShake - Send shake gesture
- setAutoRecycleTime/getAutoRecycleTime - Manage idle recycle time
- setPhoneRotation - Set portrait/landscape
- executeAdbCommand - Execute ADB command
- saveScreenShotToLocal/saveScreenShotToRemote - Screenshot functions
- setScreenResolution - Set/restore resolution and DPI
Multi-Control Features
- toggleGroupControlSync - Pause/resume sync
- joinGroupRoom - Join multi-control room
- kickItOutRoom - Kick from multi-control room
Media Injection
- injectVideoStream - Video injection control
- startMediaStream/stopMediaStream - Camera/microphone injection
- getInjectStreamStatus - Query injection status
Basic APIs
Browser Compatibility Check
### Static method to check if current browser supports RTC service
**Method Definition**
ArmcloudEngine.isSupported()
**Return Value**
`Promise<boolean>` - Returns whether the current browser supports RTC service
**Sample Code**
```javascript
const isSupported = await ArmcloudEngine.isSupported();
if (!isSupported) {
console.warn("Current browser does not support RTC service");
return false;
}
Join Room
Connect to the cloud phone and start remote control. Method Definition
engine.start(isGroupControl, pads)
Parameters
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| isGroupControl | boolean | ✗ | Enable multi-control mode | false |
| pads | string[] | ✗ | Array of instance IDs to be controlled | [] |
| Sample Code |
// Normal mode connection
engine.start(false, []);
// Multi-control mode connection
engine.start(true, ["ACXXXX", "ACXXXX"]);
Leave Room
Disconnect and release resources. Method Definition
engine.stop()
Return ValuePromise<void> - Result of the stop operation Sample Code
try {
await engine.stop();
console.log("Disconnected");
} catch (error) {
console.error("Failed to disconnect:", error);
}
Important Note: The
stop()method destroys the engine and its created DOM nodes. Before creating a newArmcloudEngine()instance to switch devices, always callstop()first.
Audio/Video Control
Set Resolution, Bitrate, Frame Rate
Adjust video stream parameters for different network conditions and quality needs. 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 | Description |
|---|---|---|---|
| definitionConfig | Object | ✓ | Video stream configuration object |
| definitionConfig.definitionId | number | ✓ | Resolution ID controlling clarity |
| definitionConfig.framerateId | number | ✓ | Frame rate ID controlling smoothness |
| definitionConfig.bitrateId | number | ✓ | Bitrate ID controlling data volume |
| forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default true |
Resolution Values (definitionId)
| ID | Resolution | Applicable Scenario |
|---|---|---|
| 7 | 144×256 | Extremely low bandwidth |
| 8 | 216×384 | Low bandwidth |
| 9 | 288×512 | Smooth mode |
| 10 | 360×640 | SD mode |
| 11 | 480×848 | Enhanced SD |
| 12 | 540×960 | HD mode |
| 13 | 600×1024 | Enhanced HD |
| 14 | 480×1280 | Widescreen mode |
| 15 | 720×1280 | Ultra HD mode |
| 16 | 720×1920 | Widescreen Ultra HD |
| 17 | 1080×1920 | Full HD |
| 18 | 1440×1920 | 2K |
| 19 | 1600×2560 | Super HD |
| 20 | 2880×1080 | Ultra-wide view |
Frame Rate Values (framerateId)
| ID | Frame Rate | Applicable Scenario |
|---|---|---|
| 1 | 20fps | Standard smoothness |
| 2 | 25fps | Enhanced smoothness |
| 3 | 30fps | High smoothness |
| 4 | 60fps | Extreme smoothness (fast motion) |
| 5 | 1fps | Minimal bandwidth (static scenes) |
| 6 | 5fps | Low bandwidth |
| 7 | 10fps | Basic smoothness |
| 8 | 15fps | Normal smoothness |
| 9 | 2fps | Ultra-low bandwidth |
Bitrate Values (bitrateId)
| ID | Bitrate | Applicable Scenario |
|---|---|---|
| 1 | 1Mbps | HD base bitrate |
| 2 | 1.5Mbps | HD enhanced bitrate |
| 3 | 2Mbps | Ultra HD base bitrate |
| 4 | 2.5Mbps | Ultra HD enhanced bitrate |
| 5 | 3Mbps | Ultra HD advanced bitrate |
| 6 | 3.5Mbps | Full HD base 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 | Super HD bitrate |
| 13 | 200kbps | Extremely low bandwidth |
| 14 | 400kbps | Low bandwidth |
| 15 | 600kbps | Smooth mode base bitrate |
Common Quality Presets
| Scenario | Recommended Config |
|---|---|
| Data-saving | { definitionId: 9, framerateId: 8, bitrateId: 15 } |
| Balanced | { definitionId: 10, framerateId: 8, bitrateId: 15 } |
| HD | { definitionId: 12, framerateId: 8, bitrateId: 1 } |
| Ultra HD | { definitionId: 15, framerateId: 1, bitrateId: 3 } |
| 2K | { definitionId: 18, framerateId: 3, bitrateId: 10 } |
Sample Code
// Set HD mode
engine.setStreamConfig({
definitionId: 12, // 540×960
framerateId: 2, // 25fps
bitrateId: 3 // 2Mbps
});
// Set smooth mode (low bandwidth)
engine.setStreamConfig({
definitionId: 9, // 288×512
framerateId: 8, // 15fps
bitrateId: 15 // 600kbps
});
// Set Ultra HD mode (high bandwidth)
engine.setStreamConfig({
definitionId: 15, // 720×1280
framerateId: 3, // 30fps
bitrateId: 5 // 3Mbps
});
Resume Streaming
Resume audio/video stream transmission. Method Definition
engine.resumeAllSubscribedStream(mediaType)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| mediaType | number | ✓ | Media type: 1 (audio), 2 (video), 3 (both) |
Sample Code
// Resume audio and video
engine.resumeAllSubscribedStream(3);
// Resume audio only
engine.resumeAllSubscribedStream(1);
// Resume video only
engine.resumeAllSubscribedStream(2);
Pause Streaming
Pause audio/video stream transmission to save bandwidth. Method Definition
engine.pauseAllSubscribedStream(mediaType)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| mediaType | number | ✓ | Media type: 1 (audio), 2 (video), 3 (both) |
Sample Code
// Pause audio and video
engine.pauseAllSubscribedStream(3);
// Pause audio only
engine.pauseAllSubscribedStream(1);
// Pause video only
engine.pauseAllSubscribedStream(2);
Mute and Unmute
Control cloud phone audio output. Method Definition
// Mute
engine.muted()
// Unmute
engine.unmuted()
Return Value None Sample Code
// Mute
engine.muted();
// Unmute
engine.unmuted();
Volume Control
Adjust cloud phone volume. Method Definition
// Increase volume
engine.increaseVolume()
// Decrease volume
engine.decreaseVolume()
Return Value None Sample Code
// Increase volume
engine.increaseVolume();
// Decrease volume
engine.decreaseVolume();
Device Control
Microphone Control
Control whether local microphone audio is sent to the cloud phone. Method Definition
engine.setMicrophone(enable)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| enable | boolean | ✓ | true to enable, false to disable microphone |
Sample Code
// Enable microphone
engine.setMicrophone(true);
// Disable microphone
engine.setMicrophone(false);
Camera Control
Control whether local camera video is sent to the cloud phone. Method Definition
engine.setCamera(enable)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| enable | boolean | ✓ | true to enable, false to disable camera |
Sample Code
// Enable camera
engine.setCamera(true);
// Disable camera
engine.setCamera(false);
Specify Device
Specify the camera or microphone device to use. Method Definition
// Specify camera
engine.setVideoDeviceId(deviceId)
// Specify microphone
engine.setAudioDeviceId(deviceId)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| deviceId | string | ✓ | Device ID; empty string for auto-select |
Sample Code
// Specify camera
engine.setVideoDeviceId('ab484e060c5f1186004457c5be97e874e976983ebf66e1227e4e925523fc4f11');
// Specify microphone
engine.setAudioDeviceId('ab484e060c5f1186004457c5be97e874e976983ebf66e1227e4e925523fc4f11');
// Auto-select
engine.setVideoDeviceId('');
engine.setAudioDeviceId('');
Enable Operation Monitoring
Enable or disable operation monitoring. Method Definition
engine.setMonitorOperation(enable: boolean, forwardOff: boolean)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| enable | boolean | ✓ | true to enable, false to disable operation monitoring |
| forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default true |
Sample Code
// Enable operation monitoring
engine.setMonitorOperation(true);
// Disable operation monitoring
engine.setMonitorOperation(false);
Input Control
Keyboard Style Control
Switch keyboard input mode. Method Definition
engine.setKeyboardStyle(keyboard)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| keyboard | string | ✓ | Keyboard mode: "local" (local IME), "pad" (cloud virtual keyboard) |
Sample Code
// Use local IME
engine.setKeyboardStyle('local');
// Use cloud virtual keyboard
engine.setKeyboardStyle('pad');
Key Command
Send system key commands. Method Definition
engine.sendCommand(command: string, forwardOff: boolean)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| command | string | ✓ | Key command: "back" (back), "home" (home), "menu" (menu); others refer to Android KeyEvent docs |
| forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default false |
Sample Code
// Send back key
engine.sendCommand("back");
// Send home key
engine.sendCommand("home");
// Send menu key
engine.sendCommand("menu");
// Send enter key
engine.sendCommand("66");
Text Input
Send text to the focused input field on the cloud phone. Method Definition
engine.sendInputString(text, forwardOff)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| text | string | ✓ | Text content to input |
| forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default false |
Sample Code
// Input text into focused field
engine.sendInputString('hello world');
Note: This only sends text to the input field; it does not update the cloud phone clipboard.
Clipboard Control
Manage cloud phone clipboard content. Method Definition
// Send text to cloud phone clipboard
engine.sendInputClipper(text, forwardOff)
// Control cloud clipboard callback
engine.saveCloudClipboard(flag)
Parameters
| Method | Parameter Name | Type | Required | Description |
|---|---|---|---|---|
| sendInputClipper | text | string | ✓ | Text content to send to clipboard |
| sendInputClipper | forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default false |
| saveCloudClipboard | flag | boolean | ✓ | true to receive clipboard callback, false to disable |
Sample Code
// Send text to cloud clipboard (long press paste in cloud input field to use)
engine.sendInputClipper('hello world');
// Enable cloud clipboard callback
engine.saveCloudClipboard(true);
// Disable cloud clipboard callback
engine.saveCloudClipboard(false);
Touch Simulation
Simulate touch and click events. Method Definition
// Simulate click
engine.triggerClickEvent(options: {
x: number; // Click X coordinate
y: number; // Click Y coordinate
width: number; // Container width
height: number; // Container height
})
// Simulate touch
engine.triggerPointerEvent(
action: number, // Touch action type
options: {
x: number; // Touch X coordinate
y: number; // Touch Y coordinate
width: number; // Container width
height: number; // Container height
}
)
Parameter Description
| Method | Parameter Name | Type | Required | Description |
|---|---|---|---|---|
| triggerClickEvent | options | Object | ✓ | Click event configuration |
| triggerClickEvent | options.x | number | ✓ | Horizontal click position |
| triggerClickEvent | options.y | number | ✓ | Vertical click position |
| triggerClickEvent | options.width | number | ✓ | Video container width |
| triggerClickEvent | options.height | number | ✓ | Video container height |
| triggerPointerEvent | action | number | ✓ | Touch action: 0 (down), 1 (up), 2 (move) |
| triggerPointerEvent | options | Object | ✓ | Touch event configuration |
| triggerPointerEvent | options.x | number | ✓ | Horizontal touch position |
| triggerPointerEvent | options.y | number | ✓ | Vertical touch position |
| triggerPointerEvent | options.width | number | ✓ | Video container width |
| triggerPointerEvent | options.height | number | ✓ | Video container height |
Coordinate Calculation: Coordinates (x,y) are relative to the video container:
- Actual X = x / width * actual video width
- Actual Y = y / height * actual video height
Sample Code
// Simulate single click
engine.triggerClickEvent({
x: 430, // Click X
y: 1383, // Click Y
width: 871, // Container width
height: 1550 // Container height
});
// Simulate swipe
// 1. Down
engine.triggerPointerEvent(0, {
x: 92, // Start X
y: 1325, // Start Y
width: 871,
height: 1550
});
// 2. Move
engine.triggerPointerEvent(2, {
x: 92,
y: 1326,
width: 871,
height: 1550
});
// 3. Up
setTimeout(() => {
engine.triggerPointerEvent(1, {
x: 92,
y: 1330, // End Y (moved vertically)
width: 871,
height: 1550
});
}, 1);
// Simulate long press
// 1. Down
engine.triggerPointerEvent(0, {
x: 300,
y: 500,
width: 871,
height: 1550
});
// 2. Up after delay
setTimeout(() => {
engine.triggerPointerEvent(1, {
x: 300,
y: 500,
width: 871,
height: 1550
});
}, 800); // Long press 800ms
Common Shortcuts
Simulate shortcuts using keyCode. Method Definition
engine.triggerKeyboardShortcut(metaState, keyCode)
Parameter Description
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| metaState | number | ✓ | Modifier state (refer to Android KeyEvent docs) |
| keyCode | number | ✓ | Key code (refer to Android KeyEvent docs) |
Sample Code
// Select all text (Ctrl + A)
engine.triggerKeyboardShortcut(8192, 29)
// Copy selected text (Ctrl + C) – triggers clipboard callback
engine.triggerKeyboardShortcut(8192, 31)
Cloud Phone Control
GPS Simulation
Set cloud phone GPS location. Method Definition
engine.setGPS(longitude, latitude)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| longitude | number | ✓ | Longitude |
| latitude | number | ✓ | Latitude |
Sample Code
// Set longitude 113, latitude 28
engine.setGPS(113, 28);
Device Control
Send device-specific commands. Method Definition
engine.sendShake(time)
Parameters
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| time | number | ✗ | Shake duration (ms) | 1500 |
Sample Code
// Default 1.5 seconds
engine.sendShake();
// 2 seconds
engine.sendShake(2000);
Note: Excessive duration may trigger multiple screenshots.
Recycle Control
Manage idle auto-recycle time. Method Definition
// Set recycle time
engine.setAutoRecycleTime(second)
// Get recycle time
engine.getAutoRecycleTime()
Parameters
| Method | Parameter Name | Type | Required | Description |
|---|---|---|---|---|
| setAutoRecycleTime | second | number | ✓ | Idle recycle time (seconds), 0–7200; 0 disables |
Return Value
| Method | Return Type | Description |
|---|---|---|
| getAutoRecycleTime | Promise<number> | Current idle recycle time (seconds) |
Sample Code
// Set 5-minute idle recycle
engine.setAutoRecycleTime(300);
// Disable auto-recycle
engine.setAutoRecycleTime(0);
// Get current recycle time
engine.getAutoRecycleTime().then(time => {
console.log(`Current idle recycle time: ${time} seconds`);
});
Screen Orientation
Set cloud phone screen orientation. Method Definition
engine.setPhoneRotation(type)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| type | number | ✓ | Orientation: 0 (portrait), 1 (landscape) |
Sample Code
// Portrait
engine.setPhoneRotation(0);
// Landscape
engine.setPhoneRotation(1);
Advanced Control
Execute ADB commands. Method Definition
engine.executeAdbCommand(command, forwardOff)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| command | string | ✓ | ADB command to execute |
| forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default true |
Sample Code
// List root directory
engine.executeAdbCommand('cd /;ls');
Screenshot
Capture cloud phone screen. Method Definition
// Save screenshot locally
engine.saveScreenShotToLocal()
// Save screenshot to cloud phone
engine.saveScreenShotToRemote()
Return Value
| Method | Return Type | Description |
|---|---|---|
| saveScreenShotToLocal | Promise<ImageData> | Screenshot image data |
| saveScreenShotToRemote | void | No return |
Sample Code
// Save screenshot locally
engine.saveScreenShotToLocal().then(imageData => {
// Create canvas
const canvas = document.createElement("canvas");
canvas.width = imageData.width;
canvas.height = imageData.height;
const ctx = canvas.getContext("2d");
// Draw image data
ctx.putImageData(imageData, 0, 0);
// Download image
const link = document.createElement("a");
link.href = canvas.toDataURL();
link.download = "screenshot.png";
link.click();
});
// Save screenshot to cloud phone gallery
engine.saveScreenShotToRemote();
Screen Resolution and DPI
Modify or restore screen resolution and DPI. Method Definition
engine.setScreenResolution(options, forwardOff)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| options.width | number | ✗ | Width |
| options.height | number | ✗ | Height |
| options.dpi | number | ✗ | DPI |
| options.type | string | ✓ | Type: "updateDensity" (update), "resetDensity" (restore default; other options ignored) |
| forwardOff | boolean | ✗ | Disable forwarding to multi-control room (effective only in multi-control), default true |
Sample Code
// Update resolution and DPI
engine.setScreenResolution({
width: 720,
height: 1280,
dpi: 360,
type: 'updateDensity'
});
// Restore default
engine.setScreenResolution({
type: 'resetDensity'
});
Multi-Control Features
Manage synchronized control of multiple cloud phones.
Sync Control
Pause or resume synchronization. Method Definition
engine.toggleGroupControlSync(flag)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| flag | boolean | ✓ | true to resume sync, false to pause |
Sample Code
// Resume sync
engine.toggleGroupControlSync(true)
// Pause sync
engine.toggleGroupControlSync(false)
Join Multi-Control Room
Method Definition
engine.joinGroupRoom(pads)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| pads | string[] | ✓ | Array of instance IDs to control |
Sample Code
// Add multiple instances to multi-control
engine.joinGroupRoom(['ACXXXX', 'ACXXXX']);
Kick from Multi-Control Room
Method Definition
engine.kickItOutRoom(pads)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| pads | string[] | ✓ | Array of instance IDs to kick |
Sample Code
// Kick specific instances
engine.kickItOutRoom(['ACXXXX']);
Media Injection
Video Injection
Inject video into cloud phone camera. Method Definition
engine.injectVideoStream(
type: "startVideoInjection" | "stopVideoInjection",
options?: {
fileUrl: string; // Video file path
isLoop?: boolean; // Loop playback
fileName?: string; // Video file name
}
)
Parameter Description
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| type | string | ✓ | Operation: "startVideoInjection" or "stopVideoInjection" | - |
| options | Object | Required when starting injection | Injection configuration | - |
| options.fileUrl | string | ✓ | Video path (cloud internal or external URL) | - |
| options.isLoop | boolean | ✗ | Loop playback | true |
| options.fileName | string | Required when fileUrl is URL | Video file name | - |
Technical Requirements
| Item | Requirement |
|---|---|
| Supported Formats | H.264, H.265 encoding |
| Resolution | Width and height must be multiples of 2 |
Sample Code
// Inject from URL
engine.injectVideoStream('startVideoInjection', {
fileUrl: 'http://example.com/video.mp4',
isLoop: true,
fileName: 'video.mp4' // Required for URL
});
// Inject from cloud internal storage
engine.injectVideoStream('startVideoInjection', {
fileUrl: '/sdcard/Downloads/video.mp4',
isLoop: true
});
// Single playback
engine.injectVideoStream('startVideoInjection', {
fileUrl: '/sdcard/Downloads/video.mp4',
isLoop: false
});
// Stop injection
engine.injectVideoStream('stopVideoInjection');
Camera/Microphone Injection
Inject local camera and microphone into cloud phone. Method Definition
// Start injection
engine.startMediaStream(mediaType)
// Stop injection
engine.stopMediaStream(mediaType)
Parameters
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| mediaType | number | ✓ | Media type: 1 (mic), 2 (camera), 3 (both) |
Sample Code
// Start camera and mic injection
engine.startMediaStream(3);
// Start mic only
engine.startMediaStream(1);
// Start camera only
engine.startMediaStream(2);
// Stop camera
engine.stopMediaStream(2);
// Stop mic
engine.stopMediaStream(1);
// Stop all
engine.stopMediaStream(3);
Injection Status Query
Get media injection status. Method Definition
engine.getInjectStreamStatus(type, timeout)
Parameters
| Parameter Name | Type | Required | Description | Default |
|---|---|---|---|---|
| type | string | ✓ | Query type: "video", "camera", "audio" | - |
| timeout | number | ✗ | Timeout (ms), 0 for no timeout | 0 |
Return Value Promise resolving to object with:
| Property | Type | Description |
|---|---|---|
| type | string | Injection type: "video", "camera", "audio" |
| status | string | Status: "live" (streaming), "offline", "unknown", "timeout" |
| path | string | Stream path (video injection only) |
Sample Code
// Query video injection status
engine.getInjectStreamStatus("video").then(res => {
console.log(`Type: ${res.type}`);
console.log(`Status: ${res.status}`);
if (res.path) {
console.log(`Path: ${res.path}`);
}
});
// Query camera status with 5s timeout
engine.getInjectStreamStatus("camera", 5000).then(res => {
console.log(`Type: ${res.type}`);
console.log(`Status: ${res.status}`);
});