Skip to main content
Version: v4

Sound Manager

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 messages and calls.

Methods

Play Sound

CometChatSoundManager.play method plays the in-built sounds audio resources for the above mentioned enum cases. 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

The SoundManager can pause different types of sounds for incoming and outgoing calls and messages using the following method:

  • pause(): This method pauses any sound currently being played.

Usage

Here is how to use CometChatSoundManager:

//Trigger the audio sound for an incoming message
CometChatSoundManager.play(Sound.incomingMessage);

//Trigger the audio sound of your choice for an incoming message
CometChatSoundManager.play(Sound.incomingMessage, "MP3_FILE_ASSET_PATH");

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

By using the CometChatSoundManager, you can enhance the user experience in your chat application by integrating audible cues for chat interactions.