[−][src]Struct ears::SoundData
Samples extracted from a file.
SoundDatas are made to be shared between several Sound and played in the same time.
Example
ⓘThis example is not tested
use ears::{Sound, SoundData, AudioController}; use std::cell::RefCell; use std::rc::Rc; fn main() -> () { // Create a SoundData let snd_data = Rc::new(RefCell::new(SoundData::new("path/to/my/sound.wav") .unwrap())); // Create two Sound with the same SoundData let mut snd1 = Sound::new_with_data(snd_data.clone()).unwrap(); let mut snd2 = Sound::new_with_data(snd_data.clone()).unwrap(); // Play the sounds snd1.play(); snd2.play(); // Wait until snd2 is playing while snd2.is_playing() {} }
Methods
impl SoundData
[src]
pub fn new(path: &str) -> Result<SoundData, String>
[src]
Create a new SoundData.
The SoundData contains all the information extracted from the file: samples and tags. It's an easy way to share the same samples between man Sounds objects.
Arguments
path
- The path of the file to load
Return
A Result
containing Ok(SoundData) on success, Err(String)
if there has been an error.
Trait Implementations
Auto Trait Implementations
impl Send for SoundData
impl Unpin for SoundData
impl Sync for SoundData
impl UnwindSafe for SoundData
impl RefUnwindSafe for SoundData
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,