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

# Sound Manager

> Manage and customize audio cues for incoming/outgoing calls and messages in CometChat Flutter UI Kit.

<Accordion title="AI Agent Component Spec">
  | Field | Value |
  | - | - |
  | Package | `cometchat_uikit_shared` |
  | Import | `import 'package:cometchat_uikit_shared/cometchat_uikit_shared.dart';` |
  | Class | `SoundManager` (singleton) |
  | Play sound | `SoundManager().play(sound: Sound.incomingMessage)` |
  | Stop sound | `SoundManager().stop()` |
  | Sound events | `incomingMessage`, `outgoingMessage`, `incomingMessageFromOther`, `incomingCall`, `outgoingCall` |
  | Source | [GitHub](https://github.com/cometchat/cometchat-uikit-flutter/tree/v5/shared_uikit/lib/src/resources) |
</Accordion>

`SoundManager` is a singleton helper class for managing and playing audio cues — incoming/outgoing calls and messages.

***

## Methods

### play

Plays the default or custom audio for a sound event.

```dart theme={null}
void play({
  required Sound sound,
  String? customSound,
  String? packageName,
  bool? isLooping,
})
```

| Parameter | Type | Description |
| - | - | - |
| `sound` | `Sound` | Required. The sound event type to play |
| `customSound` | `String?` | Optional. Asset path for custom sound file |
| `packageName` | `String?` | Optional. Package name when using sounds from another plugin |
| `isLooping` | `bool?` | Optional. Whether to loop the sound (default: `false`) |

```dart theme={null}
// Play default sounds
SoundManager().play(sound: Sound.incomingMessage);
SoundManager().play(sound: Sound.outgoingMessage);

// Play custom sound
SoundManager().play(
  sound: Sound.outgoingMessage,
  customSound: "assets/custom_sound.wav",
);

// Play looping sound (e.g., for incoming call)
SoundManager().play(
  sound: Sound.incomingCall,
  isLooping: true,
);
```

### stop

Stops any currently playing sound.

```dart theme={null}
SoundManager().stop();
```

***

## Sound Enum

| Value | Default Asset | When it plays |
| - | - | - |
| `incomingMessage` | `assets/sound/incoming_message.wav` | New message received |
| `outgoingMessage` | `assets/sound/outgoing_message.wav` | Message sent |
| `incomingMessageFromOther` | `assets/sound/incoming_message.wav` | Message from another conversation |
| `incomingCall` | `assets/sound/incoming_call.wav` | Incoming call detected |
| `outgoingCall` | `assets/sound/outgoing_call.wav` | Outgoing call initiated |

***

## Usage

```dart theme={null}
import 'package:cometchat_uikit_shared/cometchat_uikit_shared.dart';

// Play incoming message sound
SoundManager().play(sound: Sound.incomingMessage);

// Play outgoing call sound
SoundManager().play(sound: Sound.outgoingCall);

// Play custom notification sound
SoundManager().play(
  sound: Sound.incomingMessage,
  customSound: "assets/sounds/notification.mp3",
);

// Play looping ringtone for incoming call
SoundManager().play(
  sound: Sound.incomingCall,
  isLooping: true,
);

// Stop any playing sound
SoundManager().stop();
```

<Note>
  Sound behavior varies by OS when the app is in the background.
</Note>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.