> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simular.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Player

# Class: Player

Defined in: [index.d.ts:738](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L738)

Handle to a device that outputs sounds.

Dropping the `Player` (prevent this by holding a reference) stops
all its sounds.

## Constructors

### Constructor

> **new Player**(): `Player`

#### Returns

`Player`

## Accessors

### isPaused

#### Get Signature

> **get** **isPaused**(): `boolean`

Defined in: [index.d.ts:791](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L791)

Whether the player is currently paused. Players can be paused
and resumed using `pause()` and `play()`.

##### Returns

`boolean`

***

### speed

#### Get Signature

> **get** **speed**(): `number`

Defined in: [index.d.ts:781](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L781)

Playback speed of the sound.

Increasing the speed will increase the pitch by the same factor.
For example, speed `0.5` halves the frequency (lowering pitch)
and speed `2` doubles it (raising pitch). Changes in speed
affect the total duration inversely.

##### Returns

`number`

#### Set Signature

> **set** **speed**(`value`): `void`

Defined in: [index.d.ts:786](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L786)

Changes the play speed of the sound. Does not adjust the
samples, only the playback speed.

##### Parameters

###### value

`number`

##### Returns

`void`

***

### volume

#### Get Signature

> **get** **volume**(): `number`

Defined in: [index.d.ts:765](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L765)

Volume of the sound.

The value `1.0` is the "normal" volume (unfiltered input). Any
value other than `1.0` will multiply each sample by this value.

##### Returns

`number`

#### Set Signature

> **set** **volume**(`value`): `void`

Defined in: [index.d.ts:772](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L772)

Sets the volume of the sound.

The value `1.0` is the "normal" volume (unfiltered input). Any
value other than `1.0` will multiply each sample by this value.

##### Parameters

###### value

`number`

##### Returns

`void`

## Methods

### appendFile()

> **appendFile**(`path`): `void`

Defined in: [index.d.ts:745](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L745)

Decodes an audio file and appends it to the playback queue.

Supports WAV, MP3, FLAC, Vorbis/OGG, and other formats
depending on build features.

#### Parameters

##### path

`string`

#### Returns

`void`

***

### appendSamples()

> **appendSamples**(`buffer`): `void`

Defined in: [index.d.ts:747](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L747)

Appends a sound to the queue of sounds to play.

#### Parameters

##### buffer

[`SamplesBuffer`](SamplesBuffer.mdx)

#### Returns

`void`

***

### clear()

> **clear**(): `void`

Defined in: [index.d.ts:813](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L813)

Removes all currently loaded sources from the player and pauses
it.

#### Returns

`void`

***

### empty()

> **empty**(): `boolean`

Defined in: [index.d.ts:793](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L793)

Returns `true` if this player has no more sounds to play.

#### Returns

`boolean`

***

### getPos()

> **getPos**(): `number`

Defined in: [index.d.ts:808](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L808)

Returns the position of the sound that's being played, in
milliseconds.

This takes into account any speedup or delay applied.

Example: if you apply a speedup of *2* to a source and
`getPos()` returns *5000* then the position in the recording
is *10 seconds* from its start.

#### Returns

`number`

***

### len()

> **len**(): `number`

Defined in: [index.d.ts:795](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L795)

Returns the number of sounds currently in the queue.

#### Returns

`number`

***

### pause()

> **pause**(): `void`

Defined in: [index.d.ts:756](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L756)

Pauses playback of this player.

No effect if already paused. A paused player can be resumed with
`play()`.

#### Returns

`void`

***

### play()

> **play**(): `void`

Defined in: [index.d.ts:749](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L749)

Resumes playback of a paused player. No effect if not paused.

#### Returns

`void`

***

### skipOne()

> **skipOne**(): `void`

Defined in: [index.d.ts:821](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L821)

Skips to the next source in the player.

If there are more sources appended to the player at the time,
it will play the next one. Otherwise, the player will finish as
if it had finished playing a source all the way through.

#### Returns

`void`

***

### sleepUntilEnd()

> **sleepUntilEnd**(): `void`

Defined in: [index.d.ts:797](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L797)

Sleeps the current thread until the sound ends.

#### Returns

`void`

***

### stop()

> **stop**(): `void`

Defined in: [index.d.ts:758](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L758)

Stops the player by emptying the queue.

#### Returns

`void`

***

### trySeek()

> **trySeek**(`posMs`): `void`

Defined in: [index.d.ts:833](https://github.com/simular-ai/simulang-js-internal/blob/d2b85c3277cbb16ce50c0781e1db8ad2c8a5690e/index.d.ts#L833)

Attempts to seek to the given position (in milliseconds) in the
current source.

This blocks between 0 and \~5 milliseconds.

As long as the duration of the source is known, seek is
guaranteed to saturate at the end of the source. For example
given a source that reports a total duration of 42 seconds,
calling `trySeek(60000)` will seek to 42 seconds.

#### Parameters

##### posMs

`number`

#### Returns

`void`
