Ten's Thoughts

Ways to play sound on browser

October 13, 2020

Here are some lightweight code for playing sounds on browser

Audio element:

  • quick and easy setup
  • comes with player and controls

Audio buffer

  • better for short audio clips
  • easy implementation to take audio from a fetch
  • good for sound effects

Media stream

  • to receive a stream from somewhere
  • can take user devices, including mic and webcam

Oscillator

  • for manipulating the sound wave directly
  • good for creating micro-tonal sounds


Ten Zhi Yang is a dev in Singapore. Disagree with me? @ me on twitter. Like my post? @ me on twitter too!