Repository navigation
en US sdk mini program api
The authoritative entry points are the delivered miniprogram/sdk/index.js and index.d.ts, exporting AkRtcMiniClient. These SDK methods avoid requiring integrations to construct media tickets or implement signaling. Begin with the Mini Program guide; action payloads are documented in room actions.
const { AkRtcMiniClient } = require('../../sdk')
const client = new AkRtcMiniClient(events)HTTP/media initialization returns Promises. Component callbacks and view settings are generally synchronous. Catch Promise errors at the call site; asynchronous signaling/timer errors arrive through onError. Type declarations describe arguments, events and results; evolving models follow the matching public API contract.
| Method | Arguments and result | Behavior |
|---|---|---|
Static normalizeBaseUrl(value)
|
String → HTTPS origin, or empty string | Rejects HTTP/userinfo; does not establish certificate trust |
join(options) |
Required baseUrl/roomId/accessTicket; optional passcode/audio/video/mediaTransport; returns participant/capabilities/expiresAt/admissionStatus | Input intent defaults to enabled; set audio/video false for receive-only. Waiting does not grant media access. Failed post-admission initialization cleans up its session |
leave(callServer=true) |
Promise | Stops components, timers and signaling and releases media/membership. A failed media stop does not skip membership release. false is for known server-ended/local cleanup only |
setForeground(foreground) |
Boolean → Promise | Forward onHide/onShow. Background pauses capture; foreground respects user intent and host restrictions. Waiting clients do not request media |
setMediaTransport(mode='auto') |
auto/udp/tcp → void | Only auto is supported here; other values throw UNSUPPORTED_MEDIA_TRANSPORT |
getPlatformCapabilities() |
screenCapture/independentPublications/numericRemoteVolume all false | Identifies adapter limits; another platform's features do not imply support here |
await client.join({ baseUrl: meeting.baseUrl, roomId: meeting.roomId,
accessTicket: meeting.accessTicket, passcode: meeting.passcode,
audio: false, video: false, mediaTransport: 'auto' })createMeeting(settings, creator) delegates authorized creation to your business backend callback and resolves to room/host-ticket data. createDemoMeeting(baseUrl, settings), listDemoRooms(baseUrl) and issueDemoAccessTicket({baseUrl,roomId,displayName,role}) are Development helpers; role is viewer/speaker. Do not put management API tokens into a client-side creator implementation.
| Method | Input/result | Notes |
|---|---|---|
bindPusherContext(context) |
Native pusher context / this | Bind after rendering; used for stop and camera switching |
setMicrophoneEnabled(enabled), setCameraEnabled(enabled)
|
Boolean / Promise | SDK handles permission and publication. Combined publishing requires both grants; moderation can prevent enabling |
getLocalMediaState() |
micEnabled/cameraEnabled | Actual state remains false until publishing starts |
switchCamera() |
Component settings | Front/back switching with a bound context, not arbitrary hardware enumeration |
setLocalMirror(mode) |
auto/enable/disable / settings | Local preview mirror |
setPublishedMirror(enabled) |
Boolean / settings | Pusher remote-mirror setting; verify the effect on devices |
setRemoteVideoTransform(value) |
publicationId/mirror/flipVertical/rotation / settings | Target can be *; absent target applies to all remote views. Rotation is normalized to 90-degree steps; actual native rendering needs testing |
getRemoteVideoTransform(publicationId) |
ID / transform | Requested view settings, not proof of pixel processing |
setRemoteAudioVolume(value) |
0–1 / settings | Values at or below 0.01 mute; other values unmute. scalarVolumeUnsupported indicates hardware volume is required for fine control |
getAudioOutputCapabilities() |
selectable/actualRouteObservable/reason | Requested routing without physical-route readback |
getAudioOutputDevices(), setAudioOutput(id)
|
speaker/ear choices / settings | Bind sound-mode; WeChat/OS chooses the actual route |
toggleFullscreen(publicationId=''), exitFullscreen()
|
active/publicationId/mode / void | Empty ID is local, #whiteboard is whiteboard; page maximize rather than system fullscreen |
getVideoTileHeight(width,maximum,aspect) |
Numbers / layout height | Does not change the encoded publishing format |
| Method | Arguments | Purpose |
|---|---|---|
onPusherState(code,generation,publicationId) |
Native state code and component data-* | Publishing start, network/device failure; stale publication callbacks cannot activate new media |
onPusherError(detail,generation,publicationId) |
Native error detail | Reports failure and actual inactive media without exposing signed URLs |
onPusherNetStatus(info,generation,publicationId) |
Native detail or info | Actual capture format and observable publication statistics |
onPlayerState(publicationId,code,generation) |
Native statechange | Emits onPlaybackState with connecting/playing/failed |
onPlayerError(publicationId,detail,generation) |
Native error | Reports rendering/component failures |
onPlayerNetStatus(publicationId,info,generation) |
Native netstatus | Actual view dimensions; ignores stale/removed/left-session media |
onAudioVolume(publicationId,volume,generation,local) |
Volume 0–100 and local flag | Validates source before active-speaker highlighting |
retryPlayback() |
Promise | Renews playback URLs and topology only while admitted in foreground; deduplicates concurrent calls without repeatedly joining |
Bind IDs/generation from SDK state to each component:
<live-pusher id="pusher" url="{{pusherUrl}}" autopush="{{pusherUrl !== ''}}"
mode="RTC" data-generation="{{sessionGeneration}}" data-publication="{{publicationId}}"
bindstatechange="pushState" binderror="pushError" />
<live-player wx:for="{{players}}" wx:key="publicationId" src="{{item.url}}" mode="live" autoplay
data-generation="{{sessionGeneration}}" data-publication="{{item.publicationId}}"
bindstatechange="playerState" binderror="playerError" />pushState(e) { this.rtc.onPusherState(e.detail.code, e.currentTarget.dataset.generation, e.currentTarget.dataset.publication) }
pushError(e) { this.rtc.onPusherError(e.detail, e.currentTarget.dataset.generation, e.currentTarget.dataset.publication) }
playerState(e) { this.rtc.onPlayerState(e.currentTarget.dataset.publication, e.detail.code, e.currentTarget.dataset.generation) }
playerError(e) { this.rtc.onPlayerError(e.currentTarget.dataset.publication, e.detail, e.currentTarget.dataset.generation) }The four functions above are individual Page methods. Also bind muted, enable-camera, enable-mic, mirrors and sound-mode from SDK settings. The delivered Demo is the complete importable reference.
| Method | Input/result | Notes |
|---|---|---|
sendChatMessage(text,options) |
Nonempty text, optional targetParticipantId/payload | Synchronous signaling; throws before socket availability. Confirm delivery through onChatMessage |
listChatHistory(afterSequence=0,pageSize=100) |
Cursor and size 1–200 / page with rows | Server sequence; SDK deduplicates live/replayed chat |
uploadAttachment(file,options) |
Path or path/tempFilePath, purpose/caption/targetParticipantId / attachment | Requires an upload domain; server validates access and files |
downloadAttachment(value) |
Attachment ID object or same-service URL / temporary path | Rejects cross-origin destinations to protect RTC credentials |
bindWhiteboard(context,width,height) |
Canvas context and dimensions | Render and measure the Canvas first |
requestWhiteboardAccess(requestAccess=true) |
Boolean / result | Request/cancel writing; server grants remain authoritative |
sendWhiteboard(operation,payload,objectId) |
Operation, data, optional ID | Requires write permission; normally used by client.whiteboard |
sendSignal(type,payload) |
E.g. hand-raise/reaction / void | Server validates the action and payload |
client.whiteboard exposes point, setTool, setStyle, begin/move/end, text, image, undo/redo, rotate/resize, zoomBy/fit and clear. Pages supply input/layout rather than implementing another collaboration protocol.
| Method | Input/result | Boundary |
|---|---|---|
performRoomAction(action,payload={}) |
Business action / public API result | Snapshot, continuous recording, member/leadership governance; see the action reference |
moderateParticipant(id,request) |
Member ID and string/object action | kick, force-mute, allow-unmute, force-camera-off, allow-camera, etc.; cannot bypass combined-stream restrictions |
reviewAdmission(id,admit) |
Member ID and Boolean | Authorized admission review |
setRecording(enabled) |
Boolean / result | Server recording control; success is not proof of a complete recording artifact |
extendMeeting(minutes) |
Minutes / result | Server validates the permitted extension |
updateAccessPolicy(policy) |
Policy / result | Locking, invitation mode and waiting settings per the public contract |
issueInvitation(options) |
Invitee information / result | Not a management token or an indefinitely valid admission ticket |
downloadPlaybackPackage() |
Promise | Authorized in-meeting access; post-meeting archives use separate business authorization |
getVideoModes() |
Current capture information | Not a full hardware mode list or an invented exact-FPS capability |
getAvailableVideoModes(target='*') |
Member/all / mode array | Only modes actually reported by endpoints |
getEndpointInfo(), getPublicationStats()
|
Endpoint information / publication statistics | Missing metrics remain unknown/null; WebRTC RTT/loss is not available on every target |
getActiveSpeakerSupport() |
local/remote/reason | Uses WeChat canIUse for audio-volume notifications |
onSession(patch) updates joined/waiting, participant, capabilities, publication URLs and generation. onTopology(state) updates players, participants, roomPolicy, roomCapacity, recording and leadership state. onMediaSettings(settings) provides component configuration; onLocalMediaState(state) describes actual local media.
Other events are onAdmitted, onAdmissionDenied, onLeft, onRoomClosed, onKicked, onSessionExpired, onState, onError, onCaptureUnavailable, onPlaybackState, onSignal, onChatMessage, onAttachmentUploaded, onModeration, onActiveSpeakersChanged, onVideoGeometry and onWhiteboardEvent. Suppress late setData calls after page disposal while still completing SDK leave.
Do not log third-party tokens or complete signed URLs. HTTP failures may include statusCode/body. Invalid identity triggers local cleanup and onSessionExpired. Component rendering, network/codec failure and server 401/403 require different troubleshooting paths.