Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
Trigger button to play sound with no Human interaction

I have a page that has no human interaction whatsoever. The page is blank and registers an input via scanning, so everytime the user scans something, a success sound is supposed to be played. I've added a hidden button to trigger everytime a scan is read, and it is supposed to trigger the sound.

The app is used on Tablets so mouseover will not work.

I simplified my code to play the sound on the page load as it follows:

My html:

<template>
  <div id="app" v-on:datainput="dataInput">
     <q-btn label="hiddenButton" @click="playsound" id="hiddenBtn" style="visibility: hidden" />
  </div>
</template>

My JS:

   import sound from 'file'    
   export const notifications = {
    data() {
       return { 
         audio: new Audio(sound), 
       }
    },
    methods: {
      playsound: function () { 
        this.audio.play();
      },
    },
    async mounted() { 
      document.getElementById("hiddenBtn").click();
    }
   }

When I load my page the sound does not work and I get the error :

Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.

Is there a way to trigger the button the first time I load the page and play the sound with no human interaction?

I did try to mute the HTML but it did not work since I do not have a video or audio component in my html.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda