> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 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

The SoundManager plays pre-defined or custom sounds based on user interactions with the chat interface. If no custom sound file is provided, the default sound is played.

* `play()`: This method plays different types of sounds for incoming and outgoing calls and messages.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    // Play sound with default sound:
    SoundManager().play(sound: Sound.incomingMessage); //To play default incoming message sound
    SoundManager().play(sound: Sound.outgoingMessage);//To play default outgoing message sound
    ```
  </Tab>
</Tabs>

CometChat sound will behave differently with different type of OS in case of background playing

### Stop Sound

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

* `stop()`: This method Stops any sound currently being played.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    SoundManager().stop();
    ```
  </Tab>
</Tabs>

## Usage

Here is how to use SoundManager:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    //Play sound with custom sound
    SoundManager().play(sound: Sound.outgoingMessage, customSound: "assetPath"); //To custom message sound
    ```
  </Tab>
</Tabs>

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

The table below lists down various Sound enum cases and the corresponding assets played for them:

| Sound                    | Asset                              |
| ------------------------ | ---------------------------------- |
| incomingMessage          | assets/sound/incoming\_message.wav |
| outgoingMessage          | assets/sound/outgoing\_message.wav |
| incomingMessageFromOther | assets/sound/incoming\_message.wav |
| outgoingCall             | assets/sound/outgoing\_call.wav    |
| incomingCall             | assets/sound/incoming\_call.wav    |
