# @curiousmedia/sfx-player

> An audio player for controlling SFX playback in a game

Latest version **1.3.0** (published 2021-04-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @curiousmedia/sfx-player
pnpm add @curiousmedia/sfx-player
yarn add @curiousmedia/sfx-player
bun add @curiousmedia/sfx-player
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2021-04-30 |
| First published | 2019-05-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 116 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Shane Coates |
| Maintainers | cm-gregory, kyfoote, curiousjason, eaglstun, ishoa |
| Keywords | createjs, soundjs, sfx, audio, player |

## Links

- npm: https://www.npmjs.com/package/@curiousmedia/sfx-player
- npm.io page: https://npm.io/package/@curiousmedia/sfx-player

## Dependencies (1)

- [@curiousmedia/chain-controller](https://npm.io/package/@curiousmedia/chain-controller.md) ^1.3.0

## Recent versions

- 1.3.0 (latest) — 2021-04-30
- 1.2.3 — 2020-04-08
- 1.2.2 — 2020-03-26
- 1.2.1 — 2020-02-11
- 1.2.0 — 2020-01-31
- 1.1.2 — 2019-11-13
- 1.1.1 — 2019-10-28
- 1.1.0 — 2019-10-23
- 1.0.4 — 2019-05-29
- 1.0.3 — 2019-05-29
- 1.0.2 — 2019-05-29
- 1.0.1 — 2019-05-29
- 1.0.0 — 2019-05-29

## README

<a name="SFXPlayer"></a>

## SFXPlayer

An audio player for controlling SFX playback in a Game

Used to play, stop and set volume on multiple sound instances or Arrays of instances

Designed around Springroll 2.0 but not required to use

* [SFXPlayer](#SFXPlayer)
    * [new SFXPlayer(player, volume)](#new_SFXPlayer_new)
    * [.volume Setter](#volume-set)
    * [.volume Getter](#volume-get)
    * [.play(audio, options)](#play)
    * [.pause()](#pause)
    * [.resume()](#resume)
    * [.stop()](#stop)
    * [.handleInstanceComplete(event)](#handleInstanceComplete)
    * [.handleChainComplete()](#handleChainComplete)

<a name="new_SFXPlayer_new"></a>

### new SFXPlayer(volume)

Constructor

| Param | Type | Description |
| --- | --- | --- |
| volume | <code>Number</code> | volume to play sound instances at default 1 |

<a name="volume-set"></a>

### sfxPlayer.volume - Setter

Set the volume for this and the current instances playing
 
| Param | Type | Description |
| --- | --- | --- |
| volume | <code>Number</code> | volume to set |

<a name="volume-get"></a>

### sfxPlayer.volume - Getter

**Returns**: the volume of the SFXplayer
 
<a name="play"></a>

### sfxPlayer.play(audio, options)

Play an audio instance and push it to our array for tracking

**Returns**: The created Chain or the Abstract Sound Instance  
  
| Param | Type | Description |
| --- | --- | --- |
| audio | <code>String</code> | audio string UID name |
| options | <code>Object</code> | options for playing audio - default empty Object |

<a name="pause"></a>

### sfxPlayer.pause()

Pause all SFX instances
  
<a name="resume"></a>

### sfxPlayer.resume()

Resume all SFX instances
  
<a name="stop"></a>

### sfxPlayer.stop()

Stop all currently playing sound instances
  
<a name="handleInstanceComplete"></a>

### sfxPlayer.handleInstanceComplete(event)

(Private) Handle complete event called from sound instance
Remove Event Listeners
Remove the instance from our array
  
| Param | Type |
| --- | --- |
| event | <code>Event</code> | 

<a name="handleChainComplete"></a>

### sfxPlayer.handleChainComplete()

SFX has completed playing - Dispatches the 'complete' event

---
_Source: https://npm.io/package/@curiousmedia/sfx-player · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
