pub fn add(&mut self, name: &'static str, path: &str) {
        let mut file_vec: Vec<u8> = Vec::new();
        File::open(path)
            .expect("Couldn't find audio file to add.")
            .read_to_end(&mut file_vec)
            .expect("Failed reading in opened audio file.");
        let cursor = Cursor::new(file_vec);
        let decoder = Decoder::new(cursor).unwrap();
        let buffered = decoder.buffered();
        // Buffers are lazily decoded, which often leads to static on first play on low-end systems
        // or when you compile in debug mode.  Since this library is intended for educational
        // projects, those are going to be common conditions.  So, to optimize for our use-case, we
        // will pre-warm all of our audio buffers by forcing things to be decoded and cached right
        // now when we first load the file.  I would like to find a cleaner way to do this, but the
        // following scheme (iterating through a clone and discarding the decoded frames) works
        // since clones of a Buffered share the actual decoded data buffer cache by means of Arc and
        // Mutex.
        let warm = buffered.clone();
        for i in warm {
            #[allow(clippy::drop_copy)]
            drop(i);
        }
        self.clips.insert(name, buffered);
    }
/// Add an audio clip to play.  Audio clips will be decoded and buffered during this call so
/// the first call to `.play()` is not staticky if you compile in debug mode.  `name` is what
/// you will refer to this clip as when you need to play it.  Files known to be supported by the
/// underlying library (rodio) at the time of this writing are MP3, WAV, Vorbis and Flac.
Add an audio clip to play.  Audio clips will be decoded and buffered during this call so
the first call to `.play()` is not staticky if you compile in debug mode.  `name` is what
you will refer to this clip as when you need to play it.  Files known to be supported by the
underlying library (rodio) at the time of this writing are MP3, WAV, Vorbis and Flac.
Add an audio clip to play . Audio clips will be decoded and buffered during this call so the first call to ` . play () ` is not staticky if you compile in debug mode . ` name ` is what you will refer to this clip as when you need to play it . Files known to be supported by the underlying library ( rodio ) at the time of this writing are MP3 WAV Vorbis and Flac .
pub fn add(&mut self, name: &'static str, path: &str) {
        let mut file_vec: Vec<u8> = Vec::new();
        File::open(path)
            .expect("Couldn't find audio file to add.")
            .read_to_end(&mut file_vec)
            .expect("Failed reading in opened audio file.");
        let cursor = Cursor::new(file_vec);
        let decoder = Decoder::new(cursor).unwrap();
        let buffered = decoder.buffered();
        // Buffers are lazily decoded, which often leads to static on first play on low-end systems
        // or when you compile in debug mode.  Since this library is intended for educational
        // projects, those are going to be common conditions.  So, to optimize for our use-case, we
        // will pre-warm all of our audio buffers by forcing things to be decoded and cached right
        // now when we first load the file.  I would like to find a cleaner way to do this, but the
        // following scheme (iterating through a clone and discarding the decoded frames) works
        // since clones of a Buffered share the actual decoded data buffer cache by means of Arc and
        // Mutex.
        let warm = buffered.clone();
        for i in warm {
            #[allow(clippy::drop_copy)]
            drop(i);
        }
        self.clips.insert(name, buffered);
    }
pub fn add ( & mut self , name : & ' static str , path : & str ) { let mut file_vec : Vec < u8 > = Vec :: new ( ) ; File :: open ( path ) . expect ( " " ) . read_to_end ( & mut file_vec ) . expect ( " " ) ; let cursor = Cursor :: new ( file_vec ) ; let decoder = Decoder :: new ( cursor ) . unwrap ( ) ; let buffered = decoder . buffered ( ) ; // Buffers are lazily decoded, which often leads to static on first play on low-end systems // or when you compile in debug mode.  Since this library is intended for educational // projects, those are going to be common conditions.  So, to optimize for our use-case, we // will pre-warm all of our audio buffers by forcing things to be decoded and cached right // now when we first load the file.  I would like to find a cleaner way to do this, but the // following scheme (iterating through a clone and discarding the decoded frames) works // since clones of a Buffered share the actual decoded data buffer cache by means of Arc and // Mutex. let warm = buffered . clone ( ) ; for i in warm { # [ allow ( clippy drop_copy ) ] drop ( i ) ; } self . clips . insert ( name , buffered ) ; }
Add an audio clip to play.
Add an audio clip to play .
&mut self
name
&'static str
path
&str
&mut self
name
&'static str
path
&str