Skip to content

Struct AudioPlayer

zaun_client::AudioPlayer · Struct

pub struct AudioPlayer { … }

Plays AudioResources, one at a time, into every subscribed voice session.

pub fn new() -> Result<Self>

A player, idle, with its own thread.

Error::Audio when the thread cannot start.

pub fn play(&self, resource: AudioResource)

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

pub fn enqueue(&self, resource: AudioResource)

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

pub fn skip(&self)

Ends the current resource; the next queued one plays.

pub fn stop(&self)

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

pub fn pause(&self) -> bool

Pauses; false when there was nothing playing.

pub fn unpause(&self) -> bool

Resumes after pause; false when it was not paused.

pub fn status(&self) -> AudioPlayerStatus

What the player is doing.

pub fn queue_len(&self) -> usize

Resources waiting after the current one.

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

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

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

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

Debug, Drop

Full rustdoc page