0

I am facing a problem while playing sound in my website. I am applying the condition if data coming from db is equal to 1, sound should play, else it should stop .. Everything is working fine on Desktop but not working on mobile devices. here is my code below..any help will be appreciated.

HTML

<audio id="my_audio">
  <source src="../Beep.mp3" type="audio/mpeg" />
</audio>

JS

setInterval(function()
{ 
    $.ajax({
      type:"post",
      url: "actions4.php",
      data:"",
      success:function(data)
      {     
        if(data == 0){
     $('audio').get(0).load();
      $('audio').get(0).paused();
        } else {
        $('audio').get(0).load();
        $('audio').get(0).play();                 

        }
      }
    });
}, 2000);//time in milliseconds 
HerrGanzorig
  • 51
  • 1
  • 14
Syed Saqlain
  • 544
  • 4
  • 21

0 Answers0