Skip to main content

getCurrentTime

getCurrentTime(id: string): number;

Get the current playback time of a sound by its ID. Returns the time in seconds since playback started for this sound.


Example

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

soundManager.play('bells-melody');

// Get current playback position (updates in real time)
const currentTime = soundManager.getCurrentTime('bells-melody');
console.log(`Currently at ${currentTime}s`);
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).