Skip to main content
FieldValue
Package@cometchat/chat-uikit-react
Importimport { CometChatSoundManager } from "@cometchat/chat-uikit-react";
Play soundCometChatSoundManager.play(CometChatSoundManager.Sound.incomingCall) — or pass custom audio path as second arg
Pause soundCometChatSoundManager.pause()
Sound eventsincomingCall, outgoingCall, incomingMessage, incomingMessageFromOther, outgoingMessage
SourceGitHub
CometChatSoundManager is a helper class for managing and playing audio cues in the UI Kit — incoming/outgoing calls and messages. Sound is a frozen object on CometChatSoundManager, not a separate export. Access sound event keys via CometChatSoundManager.Sound.

Methods

play

Plays the default or custom audio resource for a given sound event.
ParameterTypeDescription
sound"incomingCall" | "incomingMessage" | "incomingMessageFromOther" | "outgoingCall" | "outgoingMessage"Sound event key
customSoundstring | nullOptional custom audio file URL. Defaults to null (uses built-in sound).

pause

Pauses the currently playing sound and resets playback position.

onIncomingMessage

Plays the incoming message sound directly. Accepts an optional customSound URL.

onIncomingOtherMessage

Plays the incoming message from another user sound directly. Accepts an optional customSound URL.

onOutgoingMessage

Plays the outgoing message sound directly. Accepts an optional customSound URL.

onIncomingCall

Plays the incoming call sound (loops). Accepts an optional customSound URL.

onOutgoingCall

Plays the outgoing call sound (loops). Accepts an optional customSound URL.

hasInteracted

Returns boolean — checks whether the user has interacted with the page (required by browser autoplay policies).

Sound Events

Event KeyWhen it plays
incomingCallIncoming call detected
outgoingCallOutgoing call initiated
incomingMessageNew message received from the current conversation
incomingMessageFromOtherNew message received from a different conversation
outgoingMessageMessage sent
Access via CometChatSoundManager.Sound.incomingCall, etc.

Usage

import { CometChatSoundManager } from "@cometchat/chat-uikit-react";

// Play default incoming call sound
CometChatSoundManager.play(CometChatSoundManager.Sound.incomingCall);

// Play custom sound for incoming message
CometChatSoundManager.play(CometChatSoundManager.Sound.incomingMessage, "MP3_FILE_ASSET_PATH");

// Play incoming message from other conversation
CometChatSoundManager.play(CometChatSoundManager.Sound.incomingMessageFromOther);

// Pause the ongoing sound
CometChatSoundManager.pause();

// Use individual method directly
CometChatSoundManager.onIncomingCall();
CometChatSoundManager.onOutgoingMessage("CUSTOM_AUDIO_PATH");