> For the complete documentation index, see [llms.txt](https://docs.relics.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.relics.xyz/modules/sound-module.md).

# Sound Module

**Overview**

This script is a module that manages the playback and control of sounds in the game. It provides functionalities such as playing, pausing, resuming, stopping, and adjusting the volume of sounds. It also integrates with the `Tracks` module to fetch track details.

***

**Services**

* `StarterGui`: Used to access the `RelicsXyzPlayer` GUI component.
* `MarketplaceService`: Used to fetch product information, specifically for audio assets.
* `SoundService`: A service that provides functionalities related to sound in Roblox.

***

**Data Structures**

* `SOUND`: Represents the sound component in the `RelicsXyzPlayer` GUI.
* `PlayingTrack`: A table that keeps track of the currently playing song's details, including its `id`, `image`, `title`, and `artist`.

***

**Events**

* `Played`: Triggered when a sound starts playing.
* `Paused`: Triggered when a sound is paused.
* `Resumed`: Triggered when a paused sound is resumed.
* `Stopped`: Triggered when a sound is stopped.

***

**Functions**

* `ValidateSong(songID)`:
  * **Description**: Validates if a given song ID is valid and not removed due to copyright issues.
  * **Parameters**:
    * `songID` (string): The ID of the song.
  * **Returns**: `true` if the song is valid, otherwise `false`.
* `Sound.PlayBySoundId(soundId)`:
  * **Description**: Plays a sound by its ID.
  * **Parameters**:
    * `soundId` (string): The ID of the sound.
* `Sound.Play(track)`:
  * **Description**: Plays a specific track.
  * **Parameters**:
    * `track` (table): The track details including its `id`.
* `Sound.VolumeUp()`:
  * **Description**: Increases the volume of the sound.
* `Sound.VolumeDown()`:
  * **Description**: Decreases the volume of the sound.
* `Sound.GetActive()`:
  * **Description**: Retrieves the currently active track's details.
  * **Returns**: The details of the active track.
* `Sound.Search(soundId)`:
  * **Description**: Searches for a sound by its ID and plays it.
  * **Parameters**:
    * `soundId` (string): The ID of the sound.
  * **Returns**: The details of the played sound.
* `Sound.Stop()`:
  * **Description**: Stops the currently playing sound.
* `Sound.Pause()`:
  * **Description**: Pauses the currently playing sound.
* `Sound.Resume()`:
  * **Description**: Resumes a paused sound.
* `Sound.Playing()`:
  * **Description**: Retrieves the details of the currently playing track.
  * **Returns**: The details of the playing track.
* `Sound.IsPlaying()`:
  * **Description**: Checks if a sound is currently playing.
  * **Returns**: `true` if a sound is playing, otherwise `false`.
* `Sound.IsPaused()`:
  * **Description**: Checks if a sound is currently paused.
  * **Returns**: `true` if a sound is paused, otherwise `false`.
* `Sound.Volume()`:
  * **Description**: Retrieves the current volume of the sound.
  * **Returns**: The current volume level.

***

**Usage**

To use this module in another script:

```lua
local SoundModule = require(script.Parent.Sound)  -- Adjust the path as needed

SoundModule.PlayBySoundId("7024245182")
SoundModule.VolumeUp()
local currentTrack = SoundModule.Playing()
```

***

**Notes**

* The `ValidateSong` function is crucial to ensure that the provided song ID is valid and not removed due to copyright issues.
* The `Sound` module provides a comprehensive set of functionalities to control the playback of sounds in the game, making it easier for developers to integrate sound-related features.
