README
@solid-primitives/audio
Primitive to manage audio playback in the browser. The primitives are easily composable and extended. To create your own audio element, consider using createAudioPlayer which allows you to supply a player instance that matches the built-in standard Audio API.
Each primitive also exposes the audio instance for further custom extensions. Within an SSR context this audio primitive performs noops but never interrupts the process. Time values and durations are zero'd and in LOADING state.
Installation
npm install @solid-primitives/audio
# or
yarn add @solid-primitives/audio
How to use it
createAudioPlayer
A foundational primitive with no player controls but exposes the raw player object.
const { player } = createAudioPlayer("example.wav");
createAudio
Provides a very basic interface for wrapping listeners to a supplied or default audio player.
const { play, pause } = createAudio("example.wav");
createAudioManager
Creates a very basic audio/sound player.
const { play, pause, duration, currentTime, seek, setVolume } = createAudioManager("example.wav");
Demo
You may view a working example here: https://codesandbox.io/s/solid-primitives-audio-5c9f3
Changelog
Expand Changelog
0.0.100
Pulling an early release of the package together and preparing for 1.0.0 release. No changes.
1.0.0
Minor clean-up, added tests and released.
1.0.1
Added testing and support for srcObject.
1.1.6
Added proper SSR and CJS support.
1.1.7
Updated to Solid 1.3.