Skip to main content

isPaused

Check whether a sound is paused. A paused sound keeps its position, and resume carries on from there.

isPaused(id: string): boolean;

Parameters​

ParameterTypeDefaultDescription
idstringrequiredID of the sound, stream or overlapping instance.

Returns​

boolean: true when the sound is paused. false when it is playing, stopped, or the id is not loaded.

Example​

import { SoundHub } from 'soundhub';

const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');

soundHub.play('music');

soundHub.pause('music');
soundHub.isPaused('music'); // true

soundHub.resume('music');
soundHub.isPaused('music'); // false

Try it​

Try it

Ask a sound where it is

Idle
isPlaying()false
isPaused()false
isStopped()true

Exactly one of the three is true at any moment. The values are read five times a second.

Code
Your clicks show up here as soundhub calls

Good to know​

  • A sound played with duration and pauseAtDurationReached ends up paused rather than stopped when the duration runs out.
  • stop on a paused sound makes it stopped, and its position goes back to the start.
  • For an id that is not loaded, the answer is false, but the error is also logged, stored for getLastError and dispatched as an error event.

See also​