Capítulo 303 de 859

Chapter 303: AudioLoader

Core Idea

Class for loading audio buffers. Audios are internally loaded via FileLoader.

Code Examples

const audioListener = new THREE.AudioListener();
const ambientSound = new THREE.Audio( audioListener );
const loader = new THREE.AudioLoader();
const audioBuffer = await loader.loadAsync( 'audio/ambient_ocean.ogg' );
ambientSound.setBuffer( audioBuffer );
ambientSound.play();
  • What it demonstrates: Typical usage of AudioLoader.

Reference Tables

Constructor

Signature
new AudioLoader( manager : LoadingManager )

Methods

MethodDescription
.load( url : string, onLoad : function, onProgress : onProgressCallback, onError : onErrorCallback )Starts loading from the given URL and passes the loaded audio buffer to the onLoad() callback.

Key Takeaways

  1. AudioLoader extends: Loader
  2. Key methods: load.

Connects To