Here are some lightweight code for playing sounds on browser
Audio element:
- quick and easy setup
- comes with player and controls See the Pen Playing audio via file upload and audio element by Ten Zhi Yang (@Tzyinc) on CodePen.
Audio buffer
- better for short audio clips
- easy implementation to take audio from a fetch
- good for sound effects See the Pen Playing audio via file upload and audio buffer by Ten Zhi Yang (@Tzyinc) on CodePen.
Media stream
- to receive a stream from somewhere
- can take user devices, including mic and webcam See the Pen Playing audio via media devices and media stream by Ten Zhi Yang (@Tzyinc) on CodePen.
Oscillator
- for manipulating the sound wave directly
- good for creating micro-tonal sounds See the Pen Playing audio via oscillator by Ten Zhi Yang (@Tzyinc) on CodePen.
Top comments (0)