Standard Conference Workflow
Before you begin, please confirm you've completed Enable RTC Service, Import SDK, and Initialization.
Set Up Local Event Callbacks
Set room join event callback:
engine.onRoomJoined = (int code, String? errMsg) {
if (code != 0) {
// Failed to join room
} else {
// Successfully joined room
}
};
Set resource publish event callback:
engine.onPublished = (RCRTCMediaType type, int code, String? errMsg) {
// type: Published resource type
if (code != 0) {
// Publish failed
} else {
// Publish succeeded
}
}
Set resource unpublish event callback:
engine.onUnpublished = (RCRTCMediaType type, int code, String? errMsg) {
// type: Unpublished resource type
if (code != 0) {
// Unpublish failed
} else {
// Unpublish succeeded
}
}
Set resource subscription event callback:
engine.onSubscribed = (String userId, RCRTCMediaType type, int code, String? errMsg) {
// userId: Remote user ID
// type: Subscribed resource type
if (code != 0) {
// Subscription failed
} else {
// Subscription succeeded
}
}
Set resource unsubscription event callback:
engine.onUnsubscribed = (String userId, RCRTCMediaType type, int code, String? errMsg) {
// userId: Remote user ID
// type: Unsubscribed resource type
if (code != 0) {
// Unsubscription failed
} else {
// Unsubscription succeeded
}
}
Set Up Remote Event Callbacks
Set remote user join event callback:
engine.onUserJoined = (String roomId, String userId) {
// roomId: Room ID
// userId: Remote user ID
}
Set remote user leave event callback:
engine.onUserLeft = (String roomId, String userId) {
// roomId: Room ID
// userId: Remote user ID
}
Set remote user publish event callback:
engine.onRemotePublished = (String roomId, String userId, RCRTCMediaType type) {
// roomId: Room ID
// userId: Remote user ID
// type: Published resource type
}
Set remote user unpublish event callback:
engine.onRemoteUnpublished = (String roomId, String userId, RCRTCMediaType type) {
// roomId: Room ID
// userId: Remote user ID
// type: Unpublished resource type
}
Join a Room
Join an RTC conference as a meeting member (meeting_member
):
RCRTCRoomSetup setup = RCRTCRoomSetup.create(
type: RCRTCMediaType.audio_video,
role: RCRTCRole.meeting_member,
);
engine.joinRoom('RoomID', setup);
Local Preview
Enable video capture:
engine.enableCamera(true);
Set preview window:
RCRTCView view = await RCRTCView.create();
engine.setLocalView(view);
Publish Resources
Publish audio-video resources:
engine.publish(RCRTCMediaType.audio_video);
Subscribe to Remote User Resources
After remote user publishes resources, subscribe to their audio-video streams:
engine.subscribe(userId, RCRTCMediaType.audio_video);
Set remote preview window after resource publication:
RCRTCView view = await RCRTCView.create();
engine.setRemoteView(userId, view);