Skip to main content

AudioCommand

Enum AudioCommand 

Source
#[non_exhaustive]
pub enum AudioCommand { Load { id: u32, bytes: ImageData, hint: String, max_duration: Duration, }, LoadUrl { id: u32, url: String, max_bytes: usize, max_duration: Duration, }, Play { id: u32, volume: f32, rate: f32, }, Stop { id: u32, }, Unload { id: u32, }, Open { id: u32, src: String, settings: PlayerSettings, }, Preload { id: u32, }, Resume { id: u32, }, Pause { id: u32, }, Seek { id: u32, position: Duration, }, Set { id: u32, settings: PlayerSettings, }, Close { id: u32, }, }
Expand description

What the core asks of the platform (on the root, crate::Command::Audio). Ids are the engine’s: a sound’s and a player’s are never the same.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Load

Decode sound id’s bytes into memory, at most max_duration of them, and report AudioEvent::Loaded (with truncated when there was more) or AudioEvent::Failed.

Fields

§id: u32

The sound.

§bytes: ImageData

Its encoded bytes.

§hint: String

Its file name or URL, for decoders that go by the extension.

§max_duration: Duration

How much to decode at most.

§

LoadUrl

Fetch sound id’s bytes from url (an asset:/ URI, or an http(s) URL the core checked) and decode them as Self::Load does: where the platform fetches and the core reads nothing (the web). More than max_bytes fails with AudioError::QuotaExceeded.

Fields

§id: u32

The sound.

§url: String

Where its bytes are.

§max_bytes: usize

The most bytes it may have, encoded.

§max_duration: Duration

How much to decode at most.

§

Play

Start a voice of sound id, over the ones playing.

Fields

§id: u32

The sound.

§volume: f32

Its volume, in VOLUME.

§rate: f32

Its rate, in RATE (the pitch goes with it).

§

Stop

Stop every voice of sound id.

Fields

§id: u32

The sound.

§

Unload

Free sound id’s decoded audio, its voices stopped. Nothing is reported of it after this.

Fields

§id: u32

The sound.

§

Open

Make player id for src (a URL the core checked, or an asset:/ URI), loading nothing yet.

Fields

§id: u32

The player.

§src: String

What it plays.

§settings: PlayerSettings

How it plays.

§

Preload

Load player id if it has not, without playing: its AudioEvent::Load comes when it knows its duration.

Fields

§id: u32

The player.

§

Resume

Play player id from where it is (loading it first if needed), reporting AudioEvent::Playing.

Fields

§id: u32

The player.

§

Pause

Pause player id, reporting AudioEvent::Paused.

Fields

§id: u32

The player.

§

Seek

Move player id to position (clamped to its duration).

Fields

§id: u32

The player.

§position: Duration

Where to.

§

Set

Change player id’s settings.

Fields

§id: u32

The player.

§settings: PlayerSettings

Its settings now.

§

Close

Stop and free player id. Nothing is reported of it after this.

Fields

§id: u32

The player.

Implementations§

Source§

impl AudioCommand

Source

pub fn id(&self) -> u32

The sound or player the command is about.

Source

pub fn ends(&self) -> bool

Whether nothing is reported of the object after it.

Trait Implementations§

Source§

impl Clone for AudioCommand

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AudioCommand

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for AudioCommand

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AudioCommand

Auto Trait Implementations§

§

impl !RefUnwindSafe for AudioCommand

§

impl !UnwindSafe for AudioCommand

§

impl Forget for AudioCommand

§

impl Freeze for AudioCommand
where *const ArcInner<dyn AsRef<[u8]> + Sync + Send> is !null: Freeze, PhantomData<ArcInner<dyn AsRef<[u8]> + Sync + Send>>: Freeze, *const ArcInner<Rgba> is !null: Freeze, PhantomData<ArcInner<Rgba>>: Freeze, *const u8 is !null: Freeze, PhantomData<u8>: Freeze,

§

impl Move for AudioCommand

§

impl Send for AudioCommand
where Arc<dyn AsRef<[u8]> + Sync + Send>: Send, Arc<Rgba>: Send, RawVecInner: Send,

§

impl Sync for AudioCommand
where Arc<dyn AsRef<[u8]> + Sync + Send>: Sync, Arc<Rgba>: Sync, RawVecInner: Sync,

§

impl Unpin for AudioCommand
where Arc<dyn AsRef<[u8]> + Sync + Send>: Unpin, Arc<Rgba>: Unpin, *const u8 is !null: Unpin,

§

impl UnsafeUnpin for AudioCommand
where *const ArcInner<dyn AsRef<[u8]> + Sync + Send> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn AsRef<[u8]> + Sync + Send>>: UnsafeUnpin, *const ArcInner<Rgba> is !null: UnsafeUnpin, PhantomData<ArcInner<Rgba>>: UnsafeUnpin, *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.