Skip to main content

PlayerDevice

Struct PlayerDevice 

Source
pub struct PlayerDevice<B: Backend> { /* private fields */ }
Expand description

The Audio of a backend that writes only Backend: its backend and, once the game has loaded, the Player over it. Before that there is nothing to play.

Implementations§

Source§

impl<B: Backend> PlayerDevice<B>

Source

pub const fn new(backend: B) -> Self

The device on backend, with no player yet.

Source

pub const fn backend_mut(&mut self) -> &mut B

The backend, for Player::load.

Source

pub fn set_player(&mut self, player: Player<B>)

The game has loaded: player plays from now on.

Trait Implementations§

Source§

impl<B: Backend> Audio for PlayerDevice<B>

Source§

fn music_playing(&self, now: Millis) -> Option<(&str, f64)>

The music sounding at now: its cue and the seconds since it really started (once its file had loaded), or None in silence: nothing asked for, a track still loading or whose file failed. Of two tracks sounding (a crossfade), the newest: the old one until the new one has loaded.
Source§

fn voice_playing(&self, now: Millis) -> Option<&str>

The voice clip sounding at now, by its file (SoundRequest::Voice), or asked for and still loading: None once it has ended, and for a clip stopped, replaced, whose file failed or that loaded too late to be played. A clip held by suspend still sounds. None by default, for a device that plays no voices.
Source§

fn play(&mut self, frame: &AudioFrame<'_>, now: Millis)

Plays one frame’s frame of audio at now: the volumes first, then the requests and the music commands in order. It also checks on what is still loading, so it is called every frame, with nothing to play too.
Source§

fn stop_all(&mut self)

Stops the music, the voice and the sounds started with a handle: the game has quit.
Source§

fn suspend(&mut self)

Holds everything sounding (the sounds started with a handle, the voice and the music) while the system suspends the game (SystemEvent::Suspend); sound cues played once finish. Pauses, or mutes where the backend can’t pause. A second call does nothing. Read more
Source§

fn resume(&mut self)

Brings back what suspend held, and leaves a SoundRequest::PauseSounds pause in place. A call while not suspended does nothing.
Source§

impl<B: Backend> Debug for PlayerDevice<B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<B> Freeze for PlayerDevice<B>
where B: Freeze, <B as Backend>::Playing: Freeze,

§

impl<B> RefUnwindSafe for PlayerDevice<B>

§

impl<B> Send for PlayerDevice<B>
where B: Send, <B as Backend>::Sound: Send, <B as Backend>::Loading: Send, <B as Backend>::Playing: Send,

§

impl<B> Sync for PlayerDevice<B>
where B: Sync, <B as Backend>::Sound: Sync, <B as Backend>::Loading: Sync, <B as Backend>::Playing: Sync,

§

impl<B> Unpin for PlayerDevice<B>
where B: Unpin, <B as Backend>::Loading: Unpin, <B as Backend>::Playing: Unpin,

§

impl<B> UnsafeUnpin for PlayerDevice<B>

§

impl<B> UnwindSafe for PlayerDevice<B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.