How to Get Howler.js Instance Volume

This article explains how to quickly retrieve the current volume level of a specific Howl instance in howler.js. You will learn the exact method to use, how to interpret its return value, and see a practical code example to implement in your project.

To determine the current volume level of a specific Howl instance, you call the .volume() method on that instance without passing any arguments. When invoked without parameters, this method acts as a getter and returns a float value between 0.0 (completely silent) and 1.0 (full volume).

Code Example

Here is how to initialize a sound and retrieve its volume level using JavaScript:

// Initialize the Howl instance with a specific volume
const sound = new Howl({
  src: ['audio.mp3'],
  volume: 0.755
});

// Retrieve the current volume level of this specific instance
const currentVolume = sound.volume();

console.log(currentVolume); // Outputs: 0.755

Key Details to Remember