getProgress
getProgress(id: string): number;
Get the playback progress of a sound as a ratio (0 to 1) by its ID. Returns 0 when the sound starts, 1 when playback is complete.
Example
await soundManager.loadSounds([{ id: 'bells-melody', url: 'bells-melody.mp3' }]);
soundManager.play('bells-melody');
// Get progress as 0-1 ratio
const progress = soundManager.getProgress('bells-melody');
console.log(`Progress: ${(progress * 100).toFixed(1)}%`);
Loading sound...
Progress
00:00 / 00:00Ratio: 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).