#[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
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
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
Play
Start a voice of sound id, over the ones playing.
Fields
Stop
Stop every voice of sound id.
Unload
Free sound id’s decoded audio, its voices stopped. Nothing is
reported of it after this.
Open
Make player id for src (a URL the core checked, or an
asset:/ URI), loading nothing yet.
Preload
Load player id if it has not, without playing: its
AudioEvent::Load comes when it knows its duration.
Resume
Play player id from where it is (loading it first if needed),
reporting AudioEvent::Playing.
Pause
Pause player id, reporting AudioEvent::Paused.
Seek
Move player id to position (clamped to its duration).
Set
Change player id’s settings.
Close
Stop and free player id. Nothing is reported of it after this.