Skip to main content

getProgressPercentage

getProgressPercentage(id: string): number;

Get the playback progress of a sound as a percentage (0 to 100) by its ID. Returns 0 when the sound starts, 100 when playback is complete.


Example

await soundManager.loadSounds([{ id: 'bells-melody', url: 'bells-melody.mp3' }]);

soundManager.play('bells-melody');

// Get progress as a percentage
const pct = soundManager.getProgressPercentage('bells-melody');
console.log(`Progress: ${pct.toFixed(1)}%`);
Loading sound...

Progress

00:00 / 00:00
Ratio: 0.0000%
// Get progress values
soundManager.getCurrentTime('bells-melody'); // 0.0s
soundManager.getDuration('bells-melody'); // 0.0s
soundManager.getProgress('bells-melody'); // 0.000
soundManager.getProgressPercentage('bells-melody'); // 0%
Try it: Play the bells melody sound and watch the progress values update in real time. getProgress() returns a ratio (0-1), getProgressPercentage() returns a percentage (0-100).