Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Calculadora

0

66
Vistas
Audio file playing in background once button is clicked

I have tried to get a audio file I downloaded as an mp3 to play on a webpage once a button is clicked. When I open my html with live server it is working fine. Something with connecting through heroku isn't recognizing the audio file. I've tried many tips from the internet but nothing is working. The file is in the same folder as everything else.

let button = document.querySelector('button')
let audio = new Audio("trash_Kid.mp3")

const buttonAlert = () => {
    audio.play();
    alert(`Get good kid!`)
}

button.addEventListener('click', buttonAlert)
6 months ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

Try to upload your .mp3 file in some another server and then just reference it with an absolute/external URL. Could be a Heroku limitation with audio files.

6 months ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos