getLoop
Check whether a sound is set to loop, for example to show the state of a loop button.
getLoop(id: string): boolean;
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | required | ID of the sound or stream. |
Returns
boolean: true when the sound loops. For an id that is not loaded you get false, without an error.
Example
import { SoundHub } from 'soundhub';
const soundHub = new SoundHub();
await soundHub.loadSound('music', '/audio/theme.mp3');
soundHub.getLoop('music'); // false
soundHub.setLoop('music', true);
soundHub.getLoop('music'); // true
Good to know
- It reads the
loopvalue in the sound's play options, so it reflectssetLoopand anyplay()call withloop. It says nothing aboutmaxLoopsor how many passes are left. - A new sound starts with the
loopSoundsvalue from the config,falseby default. - For a stream from
loadStreamit returns the media element'sloop.
See also
setLoop: switch looping on or off.PlayOptions: set looping when you play.