Voice Audio Service
The Voice Audio Service provides functionalities for managing audio streams in real-time communication applications. It allows users to join audio rooms, manage audio settings, and interact with other users seamlessly.
Features
- Join Audio Rooms: Users can join specific audio rooms to communicate with others.
- Mute/Unmute: Control audio input by muting or unmuting the microphone.
- Manage Seats: Users can take or leave seats in the audio room.
- Send and Receive Audio: Stream audio to other users in real-time.
- Event Handling: Handle various events related to audio management, such as adding or removing seats.
Initialization Example
final _matLiveRoomManger = MatLiveRoomManger.instance;
// Example of initalize room
await MatLiveRoomManger.instance.init(
appKey: Consts.appKey,
onInvitedToMic: (seatIndex) {},
onSendGift: (data) {},
);
//connect user
await MatLiveRoomManger.instance.connect(
roomId: widget.roomId,
name: widget.username,
avatar: images[id],
userId: Random().nextInt(10000).toString(),
metadata: '',
);
final seatService = MatLiveRoomManger.instance.seatService;
// Initialize seat layout
seatService!.initWithConfig(
MatLiveAudioRoomLayoutConfig(
rowSpacing: 16,
rowConfigs: [
MatLiveAudioRoomLayoutRowConfig(count: 4, seatSpacing: 12),
MatLiveAudioRoomLayoutRowConfig(count: 4, seatSpacing: 12),
],
),
);
Events
Add New Seats
Dynamically add new rows of seats.
_matLiveRoomManger.addSeatRow(oldCount, newCount);
Remove Seats
Remove existing rows of seats dynamically.
_matLiveRoomManger.removeSeatRow(oldCount, newCount);
UnMute Seat or Mute Seat
Toggle the microphone state for a specific seat.
final seatService = MatLiveRoomManger.instance.seatService;
final seat = seatService!.seatList.value[index];
if (!seat.currentUser.value!.isMicOnNotifier.value) {
_matLiveRoomManger.muteSeat(index);
} else {
_matLiveRoomManger.unMuteSeat(index);
}
Lock Seat
Prevent users from taking a specific seat.
_matLiveRoomManger.lockSeat(index);
UnLock Seat
Allow users to take a locked seat.
_matLiveRoomManger.unLockSeat(index);
Take Seat
Request to occupy a specific seat.
_matLiveRoomManger.requestTakeMic(seatIndex);
Switch Seat
Move to a different seat dynamically.
_matLiveRoomManger.switchSeat(toIndex);
Leave Seat
Vacate the currently occupied seat.
_matLiveRoomManger.leaveSeat(index);
Remove User From Seat
Forcefully remove a user from a specific seat.
_matLiveRoomManger.removeUserFromSeat(index);
Send Gift
Send virtual gifts to other users.
_matLiveRoomManger.sendGift(gift);
Clear Chat
Clear all chat messages in the room.
_matLiveRoomManger.clearChat();
Invite User To Take Mic
Invite a specific user to occupy a seat.
_matLiveRoomManger.inviteUserToTakeMic(userId, seatIndex);
Request Take Mic
Send a request to take the mic in a seat.
_matLiveRoomManger.requestTakeMic(seatIndex);
Send Message
Send text messages in the chat.
_matLiveRoomManger.sendMessage('text');
Libraries
- audio/define/events
- audio/define/mat_live_chat_message
- audio/define/mat_live_request_take_mic
- audio/define/mat_live_room_audio_seat
- audio/define/mat_live_user
- audio/mangers/live_room_event_receiver_manger
- audio/mangers/live_room_event_sender_manger
- audio/mangers/mat_live_room_manger
- audio/seats/mat_live_audio_room_layout_config
- audio/seats/room_seat_service
- mat_live
- services/livekit_service
- services/utlis
- utils/kprint