VMOS Cloud API
  • 简体中文
  • English
  • 简体中文
  • English
  • Product Introduction
  • Product Type
  • Product Billing
  • OpenAPI
    • User Guide
    • API Documentation
    • Error Code
    • Instance Property List
    • Android device modification attribute list
    • Callback Task Business Type Codes
    • Changelog
  • Android SDK
    • Example Construction
    • API Documentation
    • Callback Functions
    • Error Code
    • Changelog
  • Web H5 SDK
    • Example Build
    • API Documentation
    • H5 SDK Callback Functions
    • Error Code
    • Change log
  • Windows PC SDK
    • Example Setup
    • API Documentation
    • Callback Functions
    • Changelog
  • Edge-Cloud Communication Development
    • AIDL Integration Method
    • System Service API (AIDL)
  • Similar to XP, LSP Hook framework

    • Xposed-like / LSPosed Framework
    • Sensor Data Dynamic Simulation
  • Related agreements

H5 SDK Callback Functions

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

Initialization Callbacks

onInit: Initialization

Description: Callback for SDK initialization result. Signature:

onInit({ code, msg })

Parameters:

ParameterTypeDescription
codeStringInitialization result code
msgStringFailure reason
streamTypeNumberPush stream mode (2: Default mode, 3: OBS optimized mode)

Return Codes:

CodeDescription
0Initialization successful
-1Network fluctuation caused request failure (retry possible)
100006Missing required parameter in request header: token
100007Invalid token
100008Token verification failed
120001Room corresponding to pad does not exist
120002Failed to connect to cloud phone, please retry
120003Stop streaming error: command send failed
120004Stop streaming error: command service exception
120005Instance does not exist
120006UUID bound to token does not match requested UUID
120007Original token information does not exist, please check
120008Instances in current batch have different push/pull methods, contact administrator
120009padCode bound to token does not match requested padCode

Connection Callbacks

onConnectSuccess: Connection Success

Description: Triggered when start() interface succeeds. Signature:

onConnectSuccess()

onConnectFail: Connection Failure

Description: Triggered when start() interface fails. Signature:

onConnectFail({ code })

Parameters:

ParameterTypeDescription
codeNumberError code (see error code document)

onConnectionStateChanged: Connection State

Description: Connection state change callback, triggered after start succeeds when state changes. Signature:

onConnectionStateChanged(e)

Parameters:

ParameterTypeDescription
e.stateNumberConnection state code

State Codes:

State CodeDescription
0Preparing before connection, locking resources
1Disconnected
2First connection in progress
3First connection successful
4Reconnecting after disconnect
5Reconnect successful after disconnect
6Disconnected >10s without successful reconnect; SDK continues attempting

onSocketCallback: WebSocket Status

Description: WebSocket status information callback. Signature:

onSocketCallback({ code })

Parameters:

ParameterTypeDescription
codeNumberWebSocket status code

Status Codes:

Status CodeDescription
0Connected
1Closed
-1Connection failed

Media Callbacks

onRenderedFirstFrame: First Frame Rendered

Description: Triggered when video first frame is successfully rendered. Signature:

onRenderedFirstFrame(event)

Parameters:

ParameterTypeDescription
event.widthnumberResolution width
event.heightnumberResolution height
event.userIdstringUser ID
event.isScreenbooleanWhether full screen

onChangeResolution: Resolution Change

Description: Monitors resolution changes, returns old and new resolutions. Signature:

onChangeResolution({ from, to })

Parameters:

ParameterTypeDescription
fromObjectOld resolution {width, height}
toObjectNew resolution {width, height}

onAutoplayFailed: Autoplay Failed

Description: Triggered when autoplay of audio/video stream fails. Signature:

onAutoplayFailed(event)

Parameters:

ParameterTypeDescription
userIdStringUser ID of failed stream (absent if local stream failed)
kindStringMedia type ("video" or "audio")
streamIndexNumberVideo stream attribute (0: main stream, 1: screen stream)
mediaTypeNumberRemote media type (1: audio, 2: video, 3: both)

onChangeRotate: Screen Rotation

Description: Triggered on portrait/landscape switch. Signature:

onChangeRotate(type, info)

Parameters:

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

Data Capture Callbacks

onAudioInit: Audio Capture

Description: Audio data capture callback, indicates starting to receive microphone audio. Signature:

onAudioInit(audioTrackSettings)

Parameters:

ParameterTypeDescription
audioTrackSettingsObjectAudio track settings (see MediaTrackSettings)

onAudioError: Audio Error

Description: Audio data capture error callback. Signature:

onAudioError(event)

Parameters:

ParameterTypeDescription
event.codeStringError code

Error Codes:

Error CodeDescription
REPEAT_CAPTURERepeated capture
GET_AUDIO_TRACK_FAILEDAudio capture failed; check available device or if occupied by other app
STREAM_TYPE_NOT_MATCHStream type mismatch

onVideoInit: Video Capture

Description: Video data capture callback, indicates starting to receive camera video. Signature:

onVideoInit(videoTrackSettings)

Parameters:

ParameterTypeDescription
videoTrackSettingsObjectVideo track settings (see MediaTrackSettings)

onVideoError: Video Error

Description: Video data capture error callback. Signature:

onVideoError(event)

Parameters:

ParameterTypeDescription
event.codeStringError code

Error Codes:

Error CodeDescription
REPEAT_CAPTURERepeated capture
GET_AUDIO_TRACK_FAILEDAudio capture failed; check available device or if occupied by other app
STREAM_TYPE_NOT_MATCHStream type mismatch

Status Monitoring Callbacks

onErrorMessage: Playback Exception

Description: Triggered when playback exception occurs. Signature:

onErrorMessage({ code })

Parameters:

ParameterTypeDescription
codeNumberError type (0: RTC channel interrupted, 1: Error getting stats)

onRunInformation: Runtime Information

Description: Callback for current runtime info, reported every 2 seconds. Signature:

onRunInformation(stats)

Parameters:

ParameterTypeDescription
statsObjectRemote media stream stats
stats.userIdStringUser ID
stats.audioStatsObjectRemote audio stats
stats.videoStatsObjectRemote video stats

audioStats Parameters:

Parameter NameTypeDescription
audioLossRateNumberAudio packet loss rate [0, 1]
receivedKBitrateNumberReceived bitrate (kbps)
stallCountNumber|undefinedStall count in period
stallDurationNumber|undefinedStall duration (ms)
totalRttNumberEnd-to-end RTT (ms; may be inaccurate in Firefox)
statsIntervalNumberStats interval (ms)
rttNumberRTT (ms)
jitterBufferDelayNumberJitter delay (ms)
numChannelsNumberChannel count
receivedSampleRateNumberReceived sample rate
concealedSamplesNumberTotal concealed samples (PLC)
concealmentEventNumberTotal concealment events (PLC)

videoStats Parameters:

Parameter NameTypeDescription
widthNumberVideo width (px)
heightNumberVideo height (px)
videoLossRateNumberVideo packet loss rate [0, 1]
receivedKBitrateNumberReceived bitrate (kbps)
decoderOutputFrameRateNumberDecoder output frame rate (fps)
stallCountNumber|undefinedStall count in period
stallDurationNumber|undefinedStall duration (ms)
totalRttNumberEnd-to-end RTT (ms; may be inaccurate in Firefox)
isScreenBooleanWhether screen stream
statsIntervalNumberStats interval (ms)
rttNumberRTT (ms)
codecTypeStringVideo codec ("H264" or "VP8")

onNetworkQuality: Network Quality

Description: Network quality callback, reported every 2 seconds after joining room. Signature:

onNetworkQuality(uplinkNetworkQuality, downlinkNetworkQuality)

Parameters:

ParameterTypeDescription
uplinkNetworkQualityNumberUplink quality
downlinkNetworkQualityNumberDownlink quality

Quality Levels:

ValueDescription
0 (UNKNOWN)Unknown
1 (EXCELLENT)Excellent
2 (GOOD)Good (similar to EXCELLENT but possibly lower bitrate)
3 (POOR)Minor stalls, communication basically unaffected
4 (BAD)Not smooth; suggest reducing quality or audio-only mode
5 (VBAD)Very poor; suggest notifying user of weak network
6 (DOWN)Disconnected; unable to communicate

onProgress: Loading Progress

Description: Loading progress callback. Signature:

onProgress({ code, msg })

Codes:

CodeDescription
WS_CONNECT (100)WS starting connection
WS_SUCCESS (101)WS connected
WS_CLOSE (102)WS closed
WS_ERROR (103)WS error
OWN_JOIN_ROOM (200)Received join room info
RECEIVE_OFFER (201)Set offer success
RECEIVE_OFFER_ERR (202)Set offer failed
SEND_ANSWER (203)Send answer
SEND_ANSWER_ERR (204)Send answer failed
RECEIVE_ICE (205)Add ICE success
RECEIVE_ICE_ERR (206)Add ICE failed
SEND_ICE (207)Send ICE
RTC_CONNECTING (300)RTC connecting
RTC_CONNECTED (301)RTC connected
RTC_DISCONNECTED (302)RTC disconnected
RTC_CLOSE (303)RTC closed
RTC_FAILED (304)RTC failed
RTC_TRACK_VIDEO (305)RTC received video track
RTC_TRACK_VIDEO_LOAD (306)RTC video track loaded
RTC_CHANNEL_OPEN (307)RTC message channel open
RTC_CHANNEL_ERR (308)RTC message channel error
VIDEO_FIRST_FRAME (309)Video loaded before UI info
VIDEO_FIRST_FRAME (310)Video first frame rendered

User Interaction Callbacks

onUserLeaveOrJoin: User Join/Leave

Description: Triggered when user joins or leaves room. Signature:

onUserLeaveOrJoin({ type, userInfo })

Parameters:

ParameterTypeDescription
typeStringEvent type (join: join, leave: leave)
userInfoObjectUser info {userId, extraInfo}

onUserLeave: User Leave

Description: Triggered when remote user leaves room. Signature:

onUserLeave(event)

Parameters:

ParameterTypeDescription
userIdStringLeaving user ID
reasonNumberLeave reason

Leave Reasons:

ValueDescription
0 (QUIT)Active quit (called leaveRoom)
1 (DROPPED)Dropped (e.g., token expired, network)
2 (SWITCH_TO_INVISIBLE)Switched to invisible
3 (KICKED_BY_ADMIN)Kicked by admin

onUserJoined: User Join

Description: Triggered when remote user joins room. Signature:

onUserJoined({ userInfo })

Parameters:

ParameterTypeDescription
userInfo.userIdStringJoining user ID
userInfo.extraInfoStringExtra info

onAutoRecoveryTime: Idle Timeout

Description: Triggered when idle time expires. Signature:

onAutoRecoveryTime()

onMonitorOperation: Operation Info

Description: Operation monitoring info when enabled. Signature:

onMonitorOperation(event)

Parameters:

ParameterTypeDescription
event.actionTimenumberKey press time
event.actionTypenumberOperation type (down/up)
event.keyCodenumberPhysical key code
event.simulateHeightnumberScreen height
event.simulateWidthnumberScreen width
event.swipenumberSwipe distance (-1: up, 1: down)
event.touchTypestringTouch type
event.xnumberClick X coordinate
event.ynumberClick Y coordinate

Feature Callbacks

onTransparentMsg: Passthrough Message

Description: Triggered when receiving passthrough message from cloud app. Signature:

onTransparentMsg(type, msg)

Parameters:

ParameterTypeDescription
typeStringReserved (currently 0)
msgStringMessage content (string)

onOutputClipper: Content Copy

Description: Triggered when copying content on cloud phone. Signature:

onOutputClipper(data)

Parameters:

ParameterTypeDescription
data.contentStringCopied content

onAdbOutput: ADB Command Result

Description: Result after executing ADB command. Signature:

onAdbOutput(event)

Parameters:

ParameterTypeDescription
isSuccessBooleanSuccess flag
contentStringResult content on success

onInjectVideoResult: Video Injection Result

Description: Result callback for starting/stopping video injection to camera. Signature:

onInjectVideoResult(type, data)

Parameters:

ParameterTypeDescription
typeStringCallback type (startVideoInjection or stopVideoInjection)
data.isSuccessBooleanOperation success
data.contentStringFailure reason

onMediaDevicesToggle: Cloud Phone Media Device Toggle

Description: Callback when cloud phone opens/closes camera/microphone. Signature:

onMediaDevicesToggle(stats)

Parameters:

ParameterTypeDescription
stats.typeStringType: media (both), camera, microphone
stats.enabledBooleanEnabled flag
stats.isFrontBooleanFront camera (present for media and camera types)

Error Handling Callbacks

onGroupControlError: Multi-Control Error

Description: Multi-control related error callback. Signature:

onGroupControlError({ code, msg })

Parameters:

ParameterTypeDescription
codeStringError code
msgStringError message

Error Codes:

Error CodeDescription
TOKEN_ERRToken API failed
INVALID_TOKENInvalid/expired token
JOIN_ROOM_FAILEDJoin room failed
REPEAT_JOINRepeated join
ROOM_FORBIDDENRoom banned
USER_FORBIDDENUser banned

onSendUserError: Command Send Error

Description: Exception when sending remote command. Signature:

onSendUserError(error)

Parameters:

ParameterTypeDescription
error.codeStringError code

Error Codes:

Error CodeDescription
USER_MESSAGE_TIMEOUTMessage send timeout
USER_MESSAGE_BROKENChannel broken, send failed
USER_MESSAGE_NO_RECEIVERNo receiver found
USER_MESSAGE_NOT_JOINSender not joined
USER_MESSAGE_UNKNOWNUnknown error
Prev
API Documentation
Next
Error Code