Autoplay not working

Joined
Jul 9, 2018
Messages
2
Reaction score
1
I've been working on a pet project of a website with background music, no control bar, and autoplay loop. A while ago my code worked fine but now it doesn't seem to work?

<audio class="audio" controls="false" autoplay>
<source src="That Seagull Has Nothing On Me.ogg" type="audio/ogg">
<source src="That Seagull Has Nothing On Me.mp3" type="audio/mpeg">
</audio>

AND

<audio autoplay loop >
<source src="INSERT MP3 FILE NAME.ogg"
type="audio/ogg">
<source src="<INSERT MP3 FILE NAME.mp3"
type="audio/mpeg">
</audio>

Here are both codes I've used in the past. Now neither work. No autoplay, no loop and I have to have the control bar. Any ideas as to why ?
 
Joined
Jun 27, 2018
Messages
12
Reaction score
5
@D.127.0.0.1.C :
It's been quite a while since I did any thing web-based, but assuming you're using HTML5 - then the second snippet of code you posted (using html5 audio tags) should work.

Are you experiencing this problem when developing on your local machine?
Or does this problem only occur when the site is uploaded to your server and you are viewing it remotely?
Or both?

Also, which browser are you developing/testing on? And which OS?

You said that it works when you use controls in the audio tags, so the paths to the files must be OK. But it doesn't work when you use autoplay without the controls - so I'm thinking that perhaps auto-play has been disabled in your browser - that would be the first thing I'd check!

Some browsers have an option to disable autoplay for embedded audio/video in pages.
For example:
In Firefox's about:config tab - there is an option called "media.autoplay.enabled".
By default, this option is normally set to true - so autoplay will work when pages are loaded.
But if it is set to false, autoplay will not work. So any time a page is loaded and an audio or video control tries to autoplay something, the browser will simply ignore it.

So I'd recommend checking the configuration options in your browser to make sure that you haven't somehow disabled autoplay in your browser. Perhaps you have installed an add-on or a plug-in for your browser which has disabled autoplay. If this is the case, it means that your website is NOT broken, it just means that your browser is mis-configured. Therefore, re-enabling your browsers autoplay option should fix things for you.

If it isn't your browser's configuration preventing auto-play from working, then I don't know offhand.
 
Joined
Aug 6, 2018
Messages
1
Reaction score
0
I've been working on a pet project of a website with background music, no control bar, and autoplay loop. A while ago my code worked fine but now it doesn't seem to work?

<audio class="audio" controls="false" autoplay>
<source src="That Seagull Has Nothing On Me.ogg" type="audio/ogg">
<source src="That Seagull Has Nothing On Me.mp3" type="audio/mpeg">
</audio>

AND

<audio autoplay loop >
<source src="INSERT MP3 FILE NAME.ogg"
type="audio/ogg">
<source src="<INSERT MP3 FILE NAME.mp3"
type="audio/mpeg">
</audio>

Here are both codes I've used in the past. Now neither work. No autoplay, no loop and I have to have the control bar. Any ideas as to why ?

Hey,

Try the below code

<audio controls autoplay>
<source src="horse.ogg" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

Regards,
Adrian Gates
Web Developer
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top