# Struct AudioPlayer

> Plays `AudioResource`s, one at a time, into every subscribed voice session.

`zaun_client::AudioPlayer` · Struct

```rust
pub struct AudioPlayer { … }
```

Plays `AudioResource`s, one at a time, into every subscribed voice session.

## Methods

### `new`

```rust
pub fn new() -> Result<Self>
```

A player, idle, with its own thread.

# Errors
`Error::Audio` when the thread cannot start.

### `play`

```rust
pub fn play(&self, resource: AudioResource)
```

Plays `resource` now, ending the current one; the queue stays.

### `enqueue`

```rust
pub fn enqueue(&self, resource: AudioResource)
```

Plays `resource` after the current one and those queued before it.

### `skip`

```rust
pub fn skip(&self)
```

Ends the current resource; the next queued one plays.

### `stop`

```rust
pub fn stop(&self)
```

Ends the current resource and empties the queue: the player goes idle.

### `pause`

```rust
pub fn pause(&self) -> bool
```

Pauses; `false` when there was nothing playing.

### `unpause`

```rust
pub fn unpause(&self) -> bool
```

Resumes after `pause`; `false` when it was not paused.

### `status`

```rust
pub fn status(&self) -> AudioPlayerStatus
```

What the player is doing.

### `queue_len`

```rust
pub fn queue_len(&self) -> usize
```

Resources waiting after the current one.

### `next_event`

```rust
pub fn next_event(&self, timeout: Duration) -> Option<AudioPlayerEvent>
```

The next event, or `None` when none arrives within `timeout`.

### `events`

```rust
pub fn events(&self) -> impl Iterator<Item = AudioPlayerEvent> + Send + 'static
```

The events, blocking; ends when the player is dropped.

## Trait implementations

`Debug`, `Drop`

[Full rustdoc page](/docs/api/rust/zaun-client/zaun_client/voice/player/struct.AudioPlayer.html)
