# AudioClipPlayer - PsychoJS API
Keywords: psychopy, psychojs, api

# AudioClipPlayer

## sound AudioClipPlayer

This class handles the playback of an audio clip, e.g. a microphone recording.

## Constructor

#### new AudioClipPlayer(options)

Source:
  - sound/AudioClipPlayer.js, line 18

##### Parameters:

Name | Type | Description
--- | --- | ---

`options`

Object

###### Properties

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`psychoJS` | module:core.PsychoJS |  |  | the PsychoJS instance
`audioClip` | Object |  |  | the module:sound.AudioClip
`startTime` | number | <optional> | `0` | start of playback (in seconds)
`stopTime` | number | <optional> | `-1` | end of playback (in seconds)
`stereo` | boolean | <optional> | `true` | whether or not to play the sound or track in stereo
`volume` | number | <optional> | `1.0` | volume of the sound (must be between 0 and 1.0)
`loops` | number | <optional> | `0` | how many times to repeat the track or tone after it has played *

### Extends

- SoundPlayer

### Methods

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

Source:
  - sound/AudioClipPlayer.js, line 59

Determine whether this player can play the given sound.

##### Parameters:

Name | Type | Description
--- | --- | ---
`sound` | module:sound.Sound | the sound object, which should be an AudioClip

##### Returns:

an instance of AudioClipPlayer if sound is an AudioClip or undefined otherwise

Type
  Object | undefined

#### getDuration() → {number}

Source:
  - sound/AudioClipPlayer.js, line 85
Overrides:
  - SoundPlayer#getDuration

Get the duration of the AudioClip, in seconds.

##### Returns:

the duration of the clip, in seconds

Type
  number

#### play(loops, fadeDurationopt)

Source:
  - sound/AudioClipPlayer.js, line 138
Overrides:
  - SoundPlayer#play

Start playing the sound.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`loops` | number |  |  | how many times to repeat the track after it has played once. If loops == -1, the track will repeat indefinitely until stopped.
`fadeDuration` | number | <optional> | `17` | how long should the fading in last in ms

#### setDuration(duration_s)

Source:
  - sound/AudioClipPlayer.js, line 95
Overrides:
  - SoundPlayer#setDuration

Set the duration of the audio clip.

##### Parameters:

Name | Type | Description
--- | --- | ---
`duration_s` | number | the duration of the clip in seconds

#### setLoops(loops)

Source:
  - sound/AudioClipPlayer.js, line 124
Overrides:
  - SoundPlayer#setLoops

Set the number of loops.

##### Parameters:

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

#### setVolume(volume, muteopt)

Source:
  - sound/AudioClipPlayer.js, line 112
Overrides:
  - SoundPlayer#setVolume

Set the volume of the playback.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`volume` | number |  |  | the volume of the playback (must be between 0.0 and 1.0)
`mute` | boolean | <optional> | `false` | whether or not to mute the playback

#### stop(fadeDurationopt)

Source:
  - sound/AudioClipPlayer.js, line 159
Overrides:
  - SoundPlayer#stop

Stop playing the sound immediately.

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`fadeDuration` | number | <optional> | `17` | how long the fading out should last, in ms