resume
Carry on a paused sound from the point where pause left it.
resume(id: string, skipDispatchEvent?: boolean): void;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | ID of the sound or stream to resume. |
skipDispatchEvent | boolean | false | When true, no resumed event is dispatched. |
Returns
Nothing.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');
soundHub.play('music', { loop: true });
soundHub.pause('music');
// Later: continue from the saved position
soundHub.resume('music');
Try it
Resume where you paused
IdleSound'tokyo-train'
Statestopped
Play, pause, then resume. The sound continues from the same point instead of restarting.
Code
Your clicks show up here as soundhub calls
Good to know
- Does nothing unless the sound is paused. A playing or stopped sound is left alone.
- Dispatches
SoundEventsEnum.RESUMED('resumed') and notstarted. The volume, mute and fades are not applied again. - If you
seekwhile paused,resumestarts from the new position. - Works on streams from
loadStreamtoo. For an id that is not loaded, the error is logged, stored forgetLastErrorand dispatched as anerrorevent.
See also
pause: pause a sound and keep its position.resumeAllSounds: resume every paused sound.play: start a sound that is stopped.