Mini-program SDK API Reference
Complete Mini-program public surface generated from the public SDK interface definition: classes, interfaces, enums, events, error identifiers and capability scope.
Interface overview
This page lists the public API of Mini program(WeChat): classes, methods, overloads, properties, events and error codes. The interface definition matches the SDK package version.
| Checklist item | Count |
|---|---|
| Interface / class | 4 |
| Method | 32 |
| Method overloads | 45 |
| Property | 4 |
| Enums | 4 |
| error-code constants | 0 |
Availability
This platform's SDK: Generally available. The interface definition matches the SDK package version; runtime capability follows the published SDK package.
Join channel flow
Arranged in the typical call order of join / leave / publish / subscribe; the parameter table is expanded under “Parameters of the minimal runnable flow”.
| Step | Interface | Method | Overload count |
|---|---|---|---|
| Join a channel | Client | join | 1 |
| Leave a channel | Client | leave | 1 |
| publish the local track | Client | publish | 1 |
| Renew the Token | Client | renewToken | 1 |
| subscribe to remote media | Client | subscribe | 1 |
parameters for the minimal runnable flow
| Parameters | Type | Optional | Variadic parameters |
|---|---|---|---|
channelKey | string | No | No |
channel | string | No | No |
uid | number|string | No | No |
isAudioOnly | boolean | No | No |
UidType | UidType | is | No |
onSuccess | function | is | No |
onFailure | function | is | No |
onSuccess | function | is | No |
onFailure | function | is | No |
onSuccess | function | is | No |
onFailure | function | is | No |
token | string | No | No |
onSuccess | function | is | No |
onFailure | function | is | No |
uid | number | No | No |
options | object | is | No |
onSuccess | function | is | No |
onFailure | function | is | No |
Endpoint index
| Interface | Method | Property | Events |
|---|---|---|---|
ChannelMediaError | 0 | 3 | 0 |
ChannelMediaRelayConfiguration | 3 | 0 | 0 |
Client | 27 | 0 | 14 |
Log | 2 | 1 | 0 |
all endpoints
ChannelMediaError 0 method / 3 Property
| Property | Type | read-only |
|---|---|---|
code | number | No |
data | any | No |
message | string | No |
ChannelMediaRelayConfiguration 3 method / 0 Property
removeDestChannelInfo(channelName: string): void
setDestChannelInfo(channelName: string, destInfo: any): void
setSrcChannelInfo(srcInfo: any): voidMethod detail: 3 / 3 (parameters, returns, errors)
| Method | Parameters | Returns | Errors |
|---|---|---|---|
removeDestChannelInfo | channelName: string | void | Error code index |
setDestChannelInfo | channelName: string, destInfo: any | void | Error code index |
setSrcChannelInfo | srcInfo: any | void | Error code index |
Client 27 method / 0 Property
constructor(options: object): Client
destroy(onSuccess?: function, onFailure?: function): Promise<void>
init(appId: string, onSuccess?: function, onFailure?: function): Promise<void>
join(channelKey: string, channel: string, uid: number|string, isAudioOnly: boolean, UidType?: UidType, onSuccess?: function, onFailure?: function): Promise<void>
leave(onSuccess?: function, onFailure?: function): Promise<void>
mute(uid: number, target: string, onSuccess?: function, onFailure?: function): Promise<void>
muteLocal(target: string, onSuccess?: function, onFailure?: function): Promise<void>
off(event: string): void
on(event: "channel-media-relay-event", callback: function): void
on(event: "channel-media-relay-state", callback: function): void
on(event: "client-banned"): void
on(event: "error", callback: function): void
on(event: "mute-audio", callback: function): void
on(event: "mute-video", callback: function): void
on(event: "stream-added", callback: function): void
on(event: "stream-removed", callback: function): void
on(event: "token-privilege-did-expire"): void
on(event: "token-privilege-will-expire"): void
on(event: "unmute-audio", callback: function): void
on(event: "unmute-video", callback: function): void
on(event: "update-url", callback: function): void
on(event: "video-rotation", callback: function): void
publish(onSuccess?: function, onFailure?: function): Promise<string>
rejoin(channelKey: string, channel: string, uid: number|string, uids: number, isAudioOnly: boolean, UidType?: UidType, onSuccess?: function, onFailure?: function): Promise<void>
renewToken(token: string, onSuccess?: function, onFailure?: function): Promise<void>
setAudioCodec(audioCodec: AudioCodec): void
setRemoteVideoStreamType(uid: number, streamType: 0|1, onSuccess?: function, onFailure?: function): Promise<void>
setRole(role: string, onSuccess?: function, onFailure?: function): Promise<void>
startChannelMediaRelay(config: ChannelMediaRelayConfiguration, callback: function): void
stopChannelMediaRelay(callback: function): void
subscribe(uid: number, options?: object, onSuccess?: function, onFailure?: function): Promise<object>
unmute(uid: number, target: string, onSuccess?: function, onFailure?: function): Promise<void>
unmuteLocal(target: string, onSuccess?: function, onFailure?: function): Promise<void>
unpublish(onSuccess?: function, onFailure?: function): Promise<void>
unsubscribe(uid: number, onSuccess?: function, onFailure?: function): Promise<void>
updateChannelMediaRelay(config: ChannelMediaRelayConfiguration, callback: function): void
updatePlayerNetStatus(uid: number, event: any): void
updatePlayerStateChange(uid: number, event: any): void
updatePusherNetStatus(event: any): void
updatePusherStateChange(event: any): voidMethod detail: 27 / 27 (parameters, returns, errors)
| Method | Parameters | Returns | Errors |
|---|---|---|---|
constructor | options: object | Client | Error code index |
destroy | onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
init | appId: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
join | channelKey: string, channel: string, uid: number|string, isAudioOnly: boolean, UidType?: UidType, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
leave | onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
mute | uid: number, target: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
muteLocal | target: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
off | event: string | void | Error code index |
on | event: "channel-media-relay-event", callback: function | void | Error code index |
publish | onSuccess?: function, onFailure?: function | Promise<string> | Error code index |
rejoin | channelKey: string, channel: string, uid: number|string, uids: number, isAudioOnly: boolean, UidType?: UidType, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
renewToken | token: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
setAudioCodec | audioCodec: AudioCodec | void | Error code index |
setRemoteVideoStreamType | uid: number, streamType: 0|1, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
setRole | role: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
startChannelMediaRelay | config: ChannelMediaRelayConfiguration, callback: function | void | Error code index |
stopChannelMediaRelay | callback: function | void | Error code index |
subscribe | uid: number, options?: object, onSuccess?: function, onFailure?: function | Promise<object> | Error code index |
unmute | uid: number, target: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
unmuteLocal | target: string, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
unpublish | onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
unsubscribe | uid: number, onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
updateChannelMediaRelay | config: ChannelMediaRelayConfiguration, callback: function | void | Error code index |
updatePlayerNetStatus | uid: number, event: any | void | Error code index |
updatePlayerStateChange | uid: number, event: any | void | Error code index |
updatePusherNetStatus | event: any | void | Error code index |
updatePusherStateChange | event: any | void | Error code index |
| event name | callback parameters |
|---|---|
channel-media-relay-event | Function |
channel-media-relay-state | Function |
client-banned | Function |
error | Function |
mute-audio | Function |
mute-video | Function |
stream-added | Function |
stream-removed | Function |
token-privilege-did-expire | Function |
token-privilege-will-expire | Function |
unmute-audio | Function |
unmute-video | Function |
update-url | Function |
video-rotation | Function |
Log 2 method / 1 Property
setLogLevel(level: number): void
uploadLogs(onSuccess?: function, onFailure?: function): Promise<void>Method detail: 2 / 2 (parameters, returns, errors)
| Method | Parameters | Returns | Errors |
|---|---|---|---|
setLogLevel | level: number | void | Error code index |
uploadLogs | onSuccess?: function, onFailure?: function | Promise<void> | Error code index |
| Property | Type | read-only |
|---|---|---|
onLog | Function | No |
Enums
| Enums | Member count | Example value |
|---|---|---|
AudioCodec | 3 | G722 = 9 |
ENCRYPTION_MODE | 10 | AES_128_ECB = 2 |
StreamType | 2 | HIGH = null |
UidType | 2 | INT = null |
AudioCodec 3 members
| Member | value |
|---|---|
G722 | 9 |
PCMA | 8 |
PCMU | 0 |
ENCRYPTION_MODE 10 members
| Member | value |
|---|---|
AES_128_ECB | 2 |
AES_128_GCM | 5 |
AES_128_GCM2 | 7 |
AES_128_XTS | 1 |
AES_256_GCM | 6 |
AES_256_GCM2 | 8 |
AES_256_XTS | 3 |
MODE_END | 9 |
NONE | 0 |
SM4_128_ECB | 4 |
StreamType 2 members
| Member | value |
|---|---|
HIGH | null |
LOW | null |
UidType 2 members
| Member | value |
|---|---|
INT | null |
STRING | null |
error-code constants
This SDK does not expose error-code constants (see Known limitations). For platform REST error codes see Error codes; for cross-platform SDK error identifiers see SDK error identifiers.