ARMCLOUD Documentation Center
  • 简体中文
  • English
  • 简体中文
  • English
  • Product introduction
  • Product billing
  • Server OpenAPI
    • Usage Guide
    • API Signature v1.0
    • API Reference
    • Error Codes
    • Callback Business Type Codes
    • Instance List
    • Android Instance Property List
    • Changelog
  • Android SDK
    • Example Setup
    • Interface Description
    • Callback Function
    • Error Code
    • Changelog
  • Web H5 SDK
    • Example Setup
    • Interface Description
    • Callback Function
    • Error Code
    • Changelog
  • Windows PC SDK
    • Example Setup
    • Interface Description
    • Callback Function
    • Changelog
  • Edge-Cloud Communication Development
    • AIDL Access Method
    • System Service API (AIIDL)
  • Scenario solutions
    • XP-like LSP Hook framework
    • Dynamic simulation of sensor data
  • ADI Collection Tool
  • FAQ
    • Platform Basics
    • Storage
    • Network Connectivity
    • Application Management
    • Development and Integration
    • Performance Optimization
    • Billing
    • Technical Support
  • Related agreements
    • Cloud Phone SDK Privacy Policy

H5 SDK callback function reference

Unified Status Code Description: code: 0 indicates success, code: -1 indicates failure

Initialize the relevant callback

onInit: Initialization

Feature Description: SDK initialization result callback.

Signature Call:

onInit({ code, msg })

Parameter Description:

ParametersTypeDescription
codeStringInitialize the result status code
msgStringInitialization failure reasons
streamTypeNumberStreaming Mode (2. Default mode 3. OBS Optimization Mode)

Return Code Explanation:

CodeExplanation
0Initialization successful
-1Network fluctuations causing request failures (connection can be reattempted)
100006Request header information is missing, necessary parameter: token
100007Invalid tokens
100008Token verification failed
120001The room corresponding to the pad does not exist
120002Cloud machine connection failed, please try again!
120003Stream interruption error, command transmission failure
120004Stream interruption error, command service error
120005There are no instances
120006The UUID bound to the token does not match the requested UUID
120007The original token information does not exist, please check
120008There are different push-pull flow methods in the current batch instance. Please contact the administrator for assistance
120009The padCode bound to the token does not match the padCode requested

Connect related callbacks

onConnectSuccess: Connection successful

Function Description: Triggered when the start() interface is successfully called.

Signature Call:

onConnectSuccess()

onConnectFail: Connection failed

Function Description: Triggered when a call to the start() interface fails.

Signature Call:

onConnectFail({ code })

Parameter Description:

ParametersTypeDescription
codeNumberFor error codes, please refer to the error code documentation for details

onConnectionStateChanged: Connection status

Function Description: Connection status change callback, triggered when the connection status changes after a successful start.

Signature Call:

onConnectionStateChanged(e)

Parameter Description:

ParametersTypeDescription
e.stateNumberConnection status code

Status Code Description:

Status codeDescription
0Prepare before connecting and lock in related resources
1The connection is disconnected
2First connection, currently connecting
3The first connection was successful
4Disconnected and reconnected
5After the connection is disconnected, the connection is successfully reconnected
6If the device remains disconnected for more than 10 seconds and reconnects fail, the SDK will continue to attempt reconnection

onSocketCallback: WebSocket status

Feature Description: WebSocket status information callback.

Signature Call:

onSocketCallback({ code })

Parameter Description:

ParametersTypeDescription
codeNumberWebSocket status code

Status Code Description:

Status codeDescription
0Connection successful
1Connection closed
-1Connection failed

Media-related pullback

onRenderedFirstFrame: First frame rendering

Function Description: Triggered when the first frame of a video is rendered successfully.

Signature Call:

onRenderedFirstFrame(event)

Parameter Description:

ParametersTypeDescription
event.widthnumberHigh resolution
event.heightnumberHigh resolution
event.userIdstringUser ID
event.isScreenbooleanIs it full screen?

onChangeResolution: Change in resolution

Function Description: Used to monitor resolution changes and return between old and new resolutions.

Signature Call:

onChangeResolution({ from, to })

Parameter Description:

ParametersTypeDescription
fromObjectOld resolution object {width, height}
toObjectNew resolution objects {width, height}

onAutoplayFailed: Autoplay failed

Function Description: Triggered when automatic playback of audio or video streams fails.

Signature Call:

onAutoplayFailed(event)

Parameter Description:

ParametersTypeDescription
userIdStringUser ID of the stream that failed to autoplay (if not included, the local stream failed to play)
kindStringMedia types that fail to autoplay ("video" or "audio")
streamIndexNumberVideo streaming attributes (0: mainstream, 1: screen streaming)
mediaTypeNumberRemote media stream types (1: audio, 2: video, 3: audio and video)

onChangeRotate: Screen rotation

Function Description: Triggered when switching between landscape and portrait modes.

Signature Call:

onChangeRotate(type, info)

Parameter Description:

ParametersTypeDescription
typeNumberScreen orientation (0: portrait, 1: landscape)
infoObjectScreen size information: {width, height}

Data Collection Related Callbacks

onAudioInit: Audio capture

Function Description: Audio data collection callback, indicating start recording microphone sound.

Signature Call:

onAudioInit(audioTrackSettings)

Parameter Description:

ParametersTypeDescription
audioTrackSettingsObjectFor audio track settings, see MediaTrackSettings

onAudioError: Audio error

Function Description: Captures audio data error callbacks.

Signature Call:

onAudioError(event)

Parameter Description:

ParametersTypeDescription
event.codeStringError code

Error Code Explanation:

Error codeDescription
REPEAT_CAPTURERepeat collection
GET_AUDIO_TRACK_FAILEDIf audio capture fails, please check whether there are available recording devices or if other apps are taking up the space
STREAM_TYPE_NOT_MATCHStream type mismatch

onVideoInit: Video capture

Function Description: Captures video data with callback, indicating the start of receiving camera footage.

Signature Call:

onVideoInit(videoTrackSettings)

Parameter Description:

ParametersTypeDescription
videoTrackSettingsObjectFor video track settings, see MediaTrackSettings

onVideoError: Video error

Function Description: Error callback for capturing video data.

Signature Call:

onVideoError(event)

Parameter Description:

ParametersTypeDescription
event.codeStringError code

Error Code Explanation:

Error codeDescription
REPEAT_CAPTURERepeat collection
GET_AUDIO_TRACK_FAILEDIf audio capture fails, please check whether there are available recording devices or if other apps are taking up the space
STREAM_TYPE_NOT_MATCHStream type mismatch

Status monitoring callbacks

onErrorMessage: Playback Exception

Function Description: Triggered when playback is abnormal.

Signature Call:

onErrorMessage({ code })

Parameter Description:

ParametersTypeDescription
codeNumberError Types (0: RTC channel interruption, 1: Error when retrieving statistics)

onRunInformation: RunInformation

Function Description: Pullback current running information, with statistics every 2 seconds.

Signature Call:

onRunInformation(stats)

Parameter Description:

ParametersTypeDescription
statsObjectRemote media flow statistics
stats.userIdStringThe userId of the user entering the room
stats.audioStatsObjectRemote audio stream information
stats.videoStatsObjectRemote video streaming information

audioStats parameter description:

Parameter nameTypeDescription
audioLossRateNumberAudio packet loss rate (range: [0, 1])
receivedKBitrateNumberReceived bitrate (unit: kbps)
stallCountNumber|undefinedCount the number of lag times within a cycle
stallDurationNumber|undefinedStutter duration (unit: ms)
totalRttNumberFull-link round-trip latency (unit: ms; Firefox browser may not be accurate)
statsIntervalNumberStatistical interval (unit: ms)
rttNumberRound-trip delay (unit: ms)
jitterBufferDelayNumberJitter Delay (unit: ms)
numChannelsNumberThe number of sound channels
receivedSampleRateNumberReception sampling rate
concealedSamplesNumberTotal number of audio packet loss compensation (PLC) sample points
concealmentEventNumberCumulative number of audio packet loss compensation (PLC) instances

videoStats parameter description:

Parameter nameTypeDescription
widthNumberVideo width (unit: px)
heightNumberVideo height (unit: px)
videoLossRateNumberVideo packet loss rate (range: [0, 1])
receivedKBitrateNumberReceived bitrate (unit: kbps)
decoderOutputFrameRateNumberDecoder output frame rate (unit: fps)
stallCountNumber|undefinedCount the number of lag times within a cycle
stallDurationNumber|undefinedStutter duration (unit: ms)
totalRttNumberFull-link round-trip latency (unit: ms; Firefox browser may not be accurate)
isScreenBooleanIs it screen streaming?
statsIntervalNumberStatistical interval (unit: ms)
rttNumberRound-trip delay (unit: ms)
codecTypeStringVideo encoding format ("H264" or "VP8")

onNetworkQuality: Network quality

Feature Description: Network quality information callback, returns every 2 seconds after joining a room.

Signature Call:

onNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality)

Parameter Description:

ParametersTypeDescription
uplinkNetworkQualityNumberUplink network quality
downlinkNetworkQualityNumberDownlink network quality

Network Quality Level:

ValueExplanation
0 (UNKNOWN)Network quality is unknown
1 (EXCELLENT)The network quality is excellent
2 (GOOD)Good network quality (similar to EXCELLENT's subjective impression, but bitrate may be slightly lower)
3 (POOR)There was slight lag, but it basically didn't affect communication
4 (BAD)Communication is not smooth; it is recommended to reduce the sampling rate or switch to pure voice mode
5 (VBAD)The network is extremely poor, basically impossible to communicate. It is recommended to alert users that the network is weak
6 (DOWN)The network connection is disconnected, making calls impossible

onProgress: Load progress

Feature Description: Load-progress-related callbacks.

Signature Call:

onProgress({ code, msg })

Parameter Description:

CodeExplanation
WS_CONNECT (100)WS began to connect
WS_SUCCESS (101)WS connection successful
WS_CLOSE (102)WS connection is closed
WS_ERROR (103)WS connection error
OWN_JOIN_ROOM (200)Received information to join the room
RECEIVE_OFFER (201)Successfully set the offer information
RECEIVE_OFFER_ERR (202)Failed to set offer information
SEND_ANSWER (203)Send the answer message
SEND_ANSWER_ERR (204)Failed to send the answer message
RECEIVE_ICE (205)ICE information was added successfully
RECEIVE_ICE_ERR (206)Failed to add ICE information
SEND_ICE (207)Send ICE messages
RTC_CONNECTING (300)RTC is connecting
RTC_CONNECTED (301)RTC connection successful
RTC_DISCONNECTED (302)RTC disconnects
RTC_CLOSE (303)RTC connection is off
RTC_FAILED (304)RTC connection failed
RTC_TRACK_VIDEO (305)RTC receives the VIDEO stream
RTC_TRACK_VIDEO_LOAD (306)RTC successfully loads the VIDEO stream after receiving it
RTC_CHANNEL_OPEN (307)RTC message channel connection successful
RTC_CHANNEL_ERR (308)RTC message channel connection failed
VIDEO_FIRST_FRAME (309)If the VIDEO loads successfully, the cloud phone's UI message has not been received
VIDEO_FIRST_FRAME (310)The first frame of VIDEO was rendered successfully

User interaction callbacks

onUserLeaveOrJoin: Users enter and exit the room

Feature Description: Triggered when a user joins or leaves a room.

Signature Call:

onUserLeaveOrJoin({ type, userInfo })

Parameter Description:

ParametersTypeDescription
typeStringEvent Types (join: Join Room, leave: Leave Room)
userInfoObjectUser information {userId, extraInfo}

onUserLeave: User exits

Function Description: Triggered when a remote user leaves the room.

Signature Call:

onUserLeave(event)

Parameter Description:

ParametersTypeDescription
userIdStringUser ID for leaving the room
reasonNumberReasons for leaving

Explanation of Reason for Departure:

ValueExplanation
0 (QUIT)Active Exit (Call leaveRoom)
1 (DROPPED)Disconnection (such as expired tokens, network issues)
2 (SWITCH_TO_INVISIBLE)Switch to invisible (call setUserVisibility)
3 (KICKED_BY_ADMIN)Kicked out by the administrator

onUserJoined: User joined

Function Description: Triggered when a remote user joins a room.

Signature Call:

onUserJoined({ userInfo })

Parameter Description:

ParametersTypeDescription
userInfo.userIdStringUser ID of the room joined
userInfo.extraInfoStringOther information

onAutoRecoveryTime: No operation timeout

Function Description: Triggers when the operation time expires.

Signature Call:

onAutoRecoveryTime()

onMonitorOperation: Operation information

Function Description: Enable monitoring operation callback information

Signature Call:

onMonitorOperation(event)

Parameter Description:

ParametersTypeDescription
event.actionTimenumberButton time
event.actionTypenumberOperation types (such as press, lift)
event.keyCodenumberPhysical key numbering
event.simulateHeightnumberScreen height
event.simulateWidthnumberScreen width
event.swipenumberRolling distance (-1 indicates up, 1 indicates down)
event.touchTypestringKey type
event.xnumberThe X coordinate of the screen tap
event.ynumberThe Y coordinate of the screen tap

Feature Callbacks

onTransparentMsg: Transmitting messages

Function Description: Triggered when receiving a message from the cloud app.

Signature Call:

onTransparentMsg(type, msg)

Parameter Description:

ParametersTypeDescription
typeStringReserved fields (currently filled in by default 0)
msgStringMessage content (string)

onOutputClipper: Content copy

Function Description: Triggered when the cloud phone copies content.

Signature Call:

onOutputClipper(data)

Parameter Description:

ParametersTypeDescription
data.contentStringCopying content

onAdbOutput: Result of the ADB command

Function Description: Returns results after executing the ADB command.

Signature Call:

onAdbOutput(event)

Parameter Description:

ParametersTypeDescription
isSuccessBooleanWhether it succeeds
contentStringResults returned after success

onInjectVideoResult: Video injection result

Function Description: Video injection camera start or stop operation result callback.

Signature Call:

onInjectVideoResult(type, data)

Parameter Description:

ParametersTypeDescription
typeStringCallback type (startVideoInjection or stopVideoInjection)
data.isSuccessBooleanWhether the operation was successful
data.contentStringReasons for operation failure

onMediaDevicesToggle: Turning Cloud Phone On or Off (Camera/Microphone)

Function Description: Cloud device on or off (camera/microphone) callback.

Signature Call:

onMediaDevicesToggle(stats)

Parameter Description:

ParametersTypeDescription
stats.typeStringmedia: camera and microphone, camera: camera, microphone: microphone
stats.enabledBooleanWhether to open it
stats.isFrontBooleanWhether to precede or not: Note: This property only exists for types media and camera

Error handling callbacks

onGroupControlError: Group control error

Function Description: Error callbacks related to group control.

Signature Call:

onGroupControlError({ code, msg })

Parameter Description:

ParametersTypeDescription
codeStringError code
msgStringFalse information

Error Code Explanation:

Error codeDescription
TOKEN_ERRToken acquisition interface failed
INVALID_TOKENTokens are invalid or expired
JOIN_ROOM_FAILEDFailed to enter the room
REPEAT_JOINRepeated entry into the room
ROOM_FORBIDDENThe room was sealed off
USER_FORBIDDENUsers were banned

onSendUserError: Command transmission error

Function Description: Abnormalities occur when sending remote commands.

Signature Call:

onSendUserError(error)

Parameter Description:

ParametersTypeDescription
error.codeStringError code

Error Code Explanation:

Error codeDescription
USER_MESSAGE_TIMEOUTMessage timeout has passed
USER_MESSAGE_BROKENChannel disconnected, sending failed
USER_MESSAGE_NO_RECEIVERNo recipient found
USER_MESSAGE_NOT_JOINThe sender did not join the room
USER_MESSAGE_UNKNOWNUnknown errors
Prev
Interface Description
Next
Error Code