Overview
CometChatSoundManager is a helper class that manages audio playback in the CometChat UI Kit. It handles sound events for incoming and outgoing messages and calls, supporting both default sounds and custom audio files.
Methods
Play Sound
Theplay(sound:customSound:) method triggers audio playback based on user interactions with the chat interface. If no custom sound file is provided, the default sound for that event type is played.
| Parameter | Type | Description |
|---|---|---|
| sound | Sound | The type of sound event (e.g., .incomingMessage, .outgoingMessage, .incomingCall, .outgoingCall) |
| customSound | URL? | Optional URL to a custom sound file. If nil, the default sound is used. |
Pause Sound
Thepause() method stops any sound currently being played by the SoundManager.
Usage
Playing Default Sounds
Play the default sound for an incoming message:- Swift
Playing Custom Sounds
Provide a custom audio file URL to override the default sound:- Swift
Pausing Sounds
Stop any currently playing sound:- Swift
Sound Types
TheSound enum provides the following options:
| Sound Type | Description |
|---|---|
.incomingMessage | Played when a new message is received |
.outgoingMessage | Played when a message is sent |
.incomingCall | Played when an incoming call is received |
.outgoingCall | Played when initiating an outgoing call |
By using
CometChatSoundManager, you can enhance the user experience in your chat application by integrating audible cues for chat interactions.