pub fn request_sound_buffer<P: AsRef<Path>>(&self, path: P, stream: bool) -> SharedSoundBuffer {
        let mut state = self.state();

        if let Some(sound_buffer) = state.find_sound_buffer(path.as_ref()) {
            return sound_buffer;
        }

        let resource = SharedSoundBuffer::new(ResourceState::new_pending(path.as_ref().to_owned()));
        state.sound_buffers.push(TimedEntry {
            value: resource.clone(),
            time_to_live: DEFAULT_RESOURCE_LIFETIME,
        });
        let result = resource.clone();
        let path = path.as_ref().to_owned();

        #[cfg(target_arch = "wasm32")]
        crate::core::wasm_bindgen_futures::spawn_local(async move {
            load_sound_buffer(resource, path, stream).await;
        });

        #[cfg(not(target_arch = "wasm32"))]
        state.thread_pool.spawn_ok(async move {
            load_sound_buffer(resource, path, stream).await;
        });

        result
    }
/// Tries to load new sound buffer from given path or get instance of existing, if any.
/// This method is **blocking**, so it will block current thread until sound buffer is
/// loading. On failure it returns None and prints failure reason to log.
///
/// # Supported formats
///
/// Currently only WAV (uncompressed) and OGG are supported.
Tries to load new sound buffer from given path or get instance of existing, if any.
This method is **blocking**, so it will block current thread until sound buffer is
loading. On failure it returns None and prints failure reason to log.
Tries to load new sound buffer from given path or get instance of existing if any . This method is ** blocking ** so it will block current thread until sound buffer is loading . On failure it returns None and prints failure reason to log .
pub fn request_sound_buffer<P: AsRef<Path>>(&self, path: P, stream: bool) -> SharedSoundBuffer {
        let mut state = self.state();
        if let Some(sound_buffer) = state.find_sound_buffer(path.as_ref()) {
            return sound_buffer;
        }
        let resource = SharedSoundBuffer::new(ResourceState::new_pending(path.as_ref().to_owned()));
        state.sound_buffers.push(TimedEntry {
            value: resource.clone(),
            time_to_live: DEFAULT_RESOURCE_LIFETIME,
        });
        let result = resource.clone();
        let path = path.as_ref().to_owned();
        #[cfg(target_arch = "wasm32")]
        crate::core::wasm_bindgen_futures::spawn_local(async move {
            load_sound_buffer(resource, path, stream).await;
        });
        #[cfg(not(target_arch = "wasm32"))]
        state.thread_pool.spawn_ok(async move {
            load_sound_buffer(resource, path, stream).await;
        });
        result
    }
pub fn request_sound_buffer < P : AsRef < Path > > ( & self , path : P , stream : bool ) -> SharedSoundBuffer { let mut state = self . state ( ) ; if let Some ( sound_buffer ) = state . find_sound_buffer ( path . as_ref ( ) ) { return sound_buffer ; } let resource = SharedSoundBuffer :: new ( ResourceState :: new_pending ( path . as_ref ( ) . to_owned ( ) ) ) ; state . sound_buffers . push ( TimedEntry { value : resource . clone ( ) , time_to_live : DEFAULT_RESOURCE_LIFETIME , } ) ; let result = resource . clone ( ) ; let path = path . as_ref ( ) . to_owned ( ) ; # [ cfg ( target_arch " " ) ] crate :: core :: wasm_bindgen_futures :: spawn_local ( async move { load_sound_buffer ( resource , path , stream ) . await ; } ) ; # [ cfg ( not ( target_arch " " ) ) ] state . thread_pool . spawn_ok ( async move { load_sound_buffer ( resource , path , stream ) . await ; } ) ; result }
Tries to load new sound buffer from given path or get instance of existing, if any.
Tries to load new sound buffer from given path or get instance of existing if any .
&self
path
P
stream
bool
supported formats
Currently only WAV (uncompressed) and OGG are supported.
Currently only WAV ( uncompressed ) and OGG are supported .