# SoundPlayer

## sound SoundPlayer

SoundPlayer is an interface for the sound players, who are responsible for actually playing the sounds, i.e. the tracks or the tones.

Source:
  - sound/SoundPlayer.js, line 18

### Extends

- PsychObject

### Methods

#### (abstract, static) accept(sound) → {Object|undefined}

Source:
  - sound/SoundPlayer.js, line 36

Determine whether this player can play the given sound.

##### Parameters:

Name | Type | Description
--- | --- | ---
`sound` | module:sound.Sound | the sound

##### Returns:

an instance of the SoundPlayer that can play the sound, or undefined if none could be found

Type
  Object | undefined

#### (abstract) getDuration()

Source:
  - sound/SoundPlayer.js, line 79

Get the duration of the sound, in seconds.

#### (abstract) play(loopsopt)

Source:
  - sound/SoundPlayer.js, line 51

Start playing the sound.

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`loops` | number | <optional> | how many times to repeat the sound after it has played once. If loops == -1, the sound will repeat indefinitely until stopped.

#### (abstract) setDuration()

Source:
  - sound/SoundPlayer.js, line 93

Set the duration of the sound, in seconds.

#### (abstract) setLoops(loops)

Source:
  - sound/SoundPlayer.js, line 108

Set the number of loops.

##### Parameters:

Name | Type | Description
--- | --- | ---
`loops` | number | how many times to repeat the sound after it has played once. If loops == -1, the sound will repeat indefinitely until stopped.

#### (abstract) setVolume(volume, muteopt)

Source:
  - sound/SoundPlayer.js, line 124

Set the volume of the tone.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`volume` | Integer |  |  | the volume of the tone
`mute` | boolean | <optional> | `false` | whether or not to mute the tone

#### (abstract) stop()

Source:
  - sound/SoundPlayer.js, line 65

Stop playing the sound immediately.