JS to force auto-playing in modern browsers

Discussion in 'JavaScript' started by abrodski, Jul 22, 2019.

  1. #1
    Hello!
    Is there a way to use JS to bypass a recent limitation in modern browsers to autoplay music?
    I activated an autoplay in a Joomla music player plugin and I also used JS code via Custom HTML module
    <script type="text/javascript">
    var source = 'https://apostasia.ru/1.mp3';
    var audio = new Audio();
    audio.addEventListener('load', function() {
    audio.play();
    }, true);
    audio.src = source;
    audio.autoplay = true;
    </script>
    Code (JavaScript):

     
    abrodski, Jul 22, 2019 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Are you just TRYING to piss off visitors to your pages? You do know that's blocked FOR A REASON, right?

    Though a good start might be just using an AUDIO tag instead of wasting JavaScript on something that doesn't require scripting.
     
    deathshadow, Jul 25, 2019 IP