obink's avatar
Level 1

Audio tag won't autoplay

I tried many different approaches. And still can't do this.

these are everything that I tried =

<embed src="/mainAssets/christmas/song.mp3" type="audio/mp3" autostart="true" hidden="true">
        <audio
            id="player"
            autoplay controls>
            <source src="/mainAssets/christmas/song.mp3" type="audio/mp3">
        </audio>
     <audio
            onload="play()"
            controls
            autoplay
            id="myAudio"
            src="/mainAssets/christmas/song.mp3">
                Your browser does not support the
                <code>audio</code> element.
        </audio>
<iframe src="/mainAssets/christmas/song.mp3" type="audio/mp3" allow="autoplay" id="audio" ></iframe>
<audio autoplay controls>
        <source src="/mainAssets/christmas/song.mp3" type="audio/mp3">
</audio>

The audio control is working, it just the autoplay won't work as supposed to be. The main goal is to do display:none of audio and make it autoplay each time the page is loaded.

How to make the mp3 is autoplay as the background music of our website?

please help.

0 likes
6 replies
Sinnbeck's avatar

Does it work if you dont try to hide it?

obink's avatar
Level 1

hi @sinnbeck, what do you mean by to hide it?

Those codes have no property or class display of none. I mean, they are all still visible and the autoplay won't autoplay.

my plan is, the display:none will be added if the autoplay is going well.

obink's avatar
Level 1

I did read this article and also other forums with people's thoughts. And people saying, this jQuery is a bug that can't be solved.

$(document).ready(function() {
    $("#my_audio").get(0).play();
});

but sometimes I still can find a website with auto-playing music in it, like a full-ads website.

I just wanted to autoplay a Christmas song every time some visitor visit my project website :(

is there any way to do this? the autoplay audio thing.

Tray2's avatar

Not that I'm aware of no. I put some time intop checking this but I haven't found any workaround.

sMart13's avatar

@obink did you find any solution because getting same problem !

Please or to participate in this conversation.