LearnApplyShare

play sound with JavaScript

February 28, 2020 - [js, sound]

안 되는 줄 알았는데.. 찾아보니 간단히 되는구나!

요즘 웹으로 정말 안되는 게 없는 듯~

function play() {
  var audio = new Audio(
    'https://interactive-examples.mdn.mozilla.net/media/examples/t-rex-roar.mp3',
  )
  audio.play()
}

Ref.

https://stackoverflow.com/questions/9419263/playing-audio-with-javascript