[][src]Struct ears::SoundData

pub struct SoundData { /* fields omitted */ }

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

impl AudioTags for SoundData[src]

fn get_tags(&self) -> Tags[src]

Get the tags of a Sound.

Return

A borrowed pointer to the internal struct SoundTags

impl Drop for SoundData[src]

fn drop(&mut self)[src]

Destroy all the resources attached to the SoundData

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]