seek
seek(id: string, time: number, skipDispatchEvent?: boolean): void;
Seek to a specific time in a sound by its ID. Optionally, skip dispatching the seek event.
Example
// @ts-ignore
import bellsMelody from "../../assets/sounds/bells-melody.mp3";
import { SoundManager } from 'sound-manager-ts';
const soundManager = new SoundManager();
await soundManager.loadSound('bells-melody', bellsMelody);
// Start playing
soundManager.play('bells-melody');
// Seek to 15 seconds
soundManager.seek('bells-melody', 15);
// You can also use getCurrentTime() and getDuration() to build a progress UI
const duration = soundManager.getDuration('bells-melody');
const currentTime = soundManager.getCurrentTime('bells-melody');
console.log(`Progress: ${currentTime} / ${duration} seconds`);
Loading sound...
Seek Control
00:0000:00
// Seek to a specific time (in seconds)
soundManager.seek('bells-melody', 15);
Tip: Use
seek(id, time) to jump to any position in the audio. The time parameter is in seconds. Combine with getCurrentTime() andgetDuration() to build custom progress UIs.