sc0ttj / component

A tiny library for isomorphic JavaScript components
MIT License
2 stars 1 forks source link

[WIP] Feature/audio #40

Closed sc0ttj closed 3 years ago

sc0ttj commented 3 years ago

useAudio

An advanced audio add-on, which is powered by the Web Audio API, for highly performant, timing-sensitive sounds, suitable for games, and other advanced applications which need audio. It'll prob be about 3.2kb (minified and gzipped).

Works standalone (without Component), or you can attach it to Component as an add-on. If added to Component as an add-on, each component you create will have a .useAudio({ ... }) method attached to it when it's created and is then responsible for its own sounds only.

Simple standalone usage example:

const audio = useAudio({
  sound1: 'foo.mp3',
  mySound: 'bar.mp3',
});

const { mySound, sound1 } = audio;

It then allows you to use sound objects with the following methods (and more):

See advanced usage and all the options here (for now): https://github.com/sc0ttj/component/blob/feature/audio/examples/usage-audio.html#L12

TO DO