0

how can I insert local audio without displaying any control(if we can show only volume button then better) which loops itself continuously...? I tried embed tag, iframe tag, audio tag but no one is perfect some works on edge but not on chrome...

Ranjeet
  • 1
  • 2
  • 1
    Possible duplicate of [How do you hide HTML5 Audio controls?](https://stackoverflow.com/questions/5697724/how-do-you-hide-html5-audio-controls) – wokoro douye samuel Mar 10 '19 at 19:12

2 Answers2

0

Try hiding it using CSS by setting the 'display' to 'none'.

audio { 
   display:none;
}
milktae
  • 31
  • 1
  • 3
0

You can use Web Audio API to play a sound without visible control in the html page.
There is loop option you can activate to play in a loop.

const audioCtx = new (window.AudioContext || window.webkitAudioContext)();
let source = audioCtx.createBufferSource();

fetch('sample.wav')
  .then(response => response.arrayBuffer())
  .then(buffer => {
    audioCtx.decodeAudioData(buffer, data => {
      source.buffer = data;
      source.connect(audioCtx.destination);
      source.loop = true;
      source.start(0);
    })
  })

If you need, you can add a volume control with the help of a gainNode and a range slider for example.

Note some browser implementations prevent playing audio until user explicitly allows it.

TGrif
  • 5,725
  • 9
  • 31
  • 52