Skip to content

Commit

Permalink
📚 [Docs] Update API.md to cover some recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
beefchimi committed Dec 27, 2023
1 parent 6aafdcc commit f846f8a
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ sound.volume = 1;
// Mute / unmute this `Sound`.
sound.mute = true || false;

// Set the `playbackRate` for this `Sound.
// This value is a number used to multiply the speed of playback.
// Default is `1`. Min is `0.25`. Max is `4`.
sound.speed;

// Toggle the “repetition” of the `Sound`. Will
// repeat indefinitely if `true`, preventing the
// `ended` event from firing.
Expand All @@ -323,24 +328,34 @@ sound.volume;
// Get a `boolean` for whether or not this `Sound` is “mute”.
sound.mute;

// Get the current `playbackRate` for this `Sound.
sound.speed;

// Get a `boolean` for whether or not this `Sound` is
// to repeat indefinitely.
sound.loop;

// Get the “total play time” for this `Sound`.
sound.duration;

// Get the current `SoundProgressEvent` for this `Sound.
sound.progress;

// Get the current `state` for this `Sound`. Can be:
// `created`, `playing`, `paused`, or `stopping`.
sound.duration;
// `created`, `playing`, `paused`, `stopping`, or `ending`.
sound.state;

// Get an array of all the events for this instance
// that currently have listeners attached.
sound.activeEvents;
```

**Events:**

```ts
// Event called whenever `Sound > state` is changed.
// Possible `SoundState` values are:
// `created`, `playing`, `paused`, and `stopping`.
// `created`, `playing`, `paused`, `stopping`, and `ending`.
(event: 'state', listener: (current: SoundState) => void)

// Event called on the audio `source` node whenenver
Expand All @@ -354,6 +369,14 @@ sound.duration;

// Event called whenever the `mute` property changes.
(event: 'mute', listener: (muted: boolean) => void)

// Event called for every animation frame while `playing`.
// Returns data representing:
// elapsed: “seconds” into the current iteration of this `Sound`.
// remaining: “seconds” until the end of the current iteration of this `Sound`.
// percentage: “percentage progressed” into the current iteration of this `Sound`.
// iterations: number of times this `Sound` has looped.
(event: 'progress', listener: ({elapsed, remaining, percentage, iterations}: SoundProgressEvent) => void)
```

## Events API
Expand Down

0 comments on commit f846f8a

Please sign in to comment.