AI Agent Component Spec
AI Agent Component Spec
- Package:
@cometchat/chat-uikit-react - Import:
import { CometChatSoundManager, Sound } from "@cometchat/chat-uikit-react"; - Play sound:
CometChatSoundManager.play(Sound.incomingCall)— or pass custom MP3 path as second arg - Pause sound:
CometChatSoundManager.pause() - Sound events:
Sound.incomingCall,Sound.outgoingCall,Sound.incomingMessage,Sound.outgoingMessage
Overview
The SoundManager is a helper class responsible for managing and playing various types of audio in the CometChat UI Kit. This includes sound events for incoming and outgoing calls.Methods
Play Sound
CometChatSoundManager.play method plays the default audio resource for incoming & outgoing calls. It also allows for customisation of the audio resources. You can pass a mp3 file asset path of your choice.
Here are the available methods for triggering sound playback:
-
play(sound: Sound): This method plays predefined sounds for various events such as incoming and outgoing calls and messages. -
play(sound: Sound, filePath: string): This method is capable of playing a custom sound for a particular event by specifying the path to a custom MP3 file.
Pause Sound
TheCometChatSoundManager.pause method pauses the currently playing sound in the CometChatSoundManager.
pause(): This method pauses any sound currently being played.
Usage
Here is how to use CometChatSoundManager:- JavaScript
- TypeScript
Common Failure Modes
Common Failure Modes
Common Failure Modes
| Symptom | Cause | Fix |
|---|---|---|
| No sound plays | Browser autoplay policy blocks audio | User must interact with the page first before audio can play |
| Custom sound not playing | Invalid file path or unsupported format | Ensure the path is correct and the file is a valid MP3 |
| Sound keeps playing | pause() not called | Call CometChatSoundManager.pause() to stop playback |
Next Steps
Localize
Configure multi-language localization and date formatting.
Theme
Customize colors, fonts, and styles.
Components Overview
Explore all available prebuilt UI components.
Methods
Init, login, logout, and other UI Kit methods.