Jump to content
xisto Community
M6NEN

Google Chrome and media files

Recommended Posts

Since April 2018, Google Chrome decided to stop allowing media files (be it video with sound or just sound files) to start automatically on a website.

This time (this rarely happens) I have been caught out.

The problem is, I have a website where I want an mp3 file to start playing automatically when the page loads (invisible, with no controls), and I, myself use Google Chrome 68.0.3440.106 (the latest version at the time of posting).

 

To my astonishment, when the page loads, nothing happens, and I say "to my astonishment", as I have used exactly the same code as I used on another web page, where the MP3 file DOES play as expected.

The code is:

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

As I said, on my other website, with exactly the same code, the MP3 file starts playing immediately and flawlessly, while on the site I am working on now, not a single note plays.

I have read tons of advice on a vast number of websites, most of them say it is simply the bit "type="audio/mpeg" that is supposed to do the trick, while others advise using an iframe, and then there are people who say you have to resort to using Java and/or Javascript, some of the code they give can even get very lengthy.

 

Now, what I would like to know is, is there anyone who knows a solution that works, and keeps working, as I have had no joy with anything I read and tried in all the things I have gone through so far.

And what baffles me even more is that, using EXACTLY the same code as I did on another website were it works perfectly, it just refuses to work this time.

 

Any help will be much appreciated.

 

Share this post


Link to post
Share on other sites

By the way, personally,  I hate websites starting things I don't master. I stopped visiting websites opening invisible windows playing music or saying sentences like "hey, buy my thing"!

Share this post


Link to post
Share on other sites

OK, granted,

but this is not about a spam window or an annoying popup (which I hate as well) opening up.

It is only a piece of music playing while you are looking at the page.

 

Share this post


Link to post
Share on other sites
6 minutes ago, M6NEN said:

It is only a piece of music playing while you are looking at the page.

OK, I understand. However, I want to master whether music should be playing or not while I am looking at a webpage.

Moreover, sometimes when I am at work, sometimes I need help and I use to ask google. Some results arise, and If I click on the wrong link, it should start no music, else I will not  be considered as a serious worker and I will loose my job. T_T

Share this post


Link to post
Share on other sites
2 minutes ago, yordan said:

OK, I understand. However, I want to master whether music should be playing or not while I am looking at a webpage.

Moreover, sometimes when I am at work, sometimes I need help and I use to ask google. Some results arise, and If I click on the wrong link, it should start no music, else I will not  be considered as a serious worker and I will loose my job. T_T

Oh dear, another one joining the dole queue then.

Bad thing for the economy, i would say.

 

However, this question was meant to be technical, not about the philosophies of life or what people like or not while surfing.

Just a question about how to deal with a certain issue, and, moreover, expressing my astonishment about how exactly the same HTML code can work on one web page and not on another.

That is all it was, in other words, that is what the topic was (choosing my words carefully this time).

Since my real intelligence is failing, I might try it with the artificial stuff, who knows?

 

Share this post


Link to post
Share on other sites

Sorry, you are right.

I did not have any technical answer, so I replied with my deep feeling. So maybe we should also open another thread concerning economy. Are popups and ads and unwanted music necessary for the economy ?

Share this post


Link to post
Share on other sites

Sure, why don't we do that?

Because those ads and popups (not necessarily music, being a musician) do my head in and often serve no purpose whatsoever except to annoy people, or leading to useless sites or broken links or even filling your machine with spyware and such rubbish.

 

See, I can even answer seriously to sarcasm.

 

There is one thing I NEVER put on my websites and that is popups or third party ads or similar rubbish, apart from the cookies banner at the top or bottom, which has now become an obligation according to EU privacy rules and only occurs on a visitor's first visit (unless (s)he clears his/her cookies).

And, for users with some sense, what would be the use, they would use (as I do) a popup blocker anyway.

While I know that some "serious" sites still make use of these kind of things, they are definitely not my thing at all, so I am definitely not going to implement them.

 

 

Edited by M6NEN (see edit history)

Share this post


Link to post
Share on other sites
20 hours ago, OpaQue said:

If Chrome is not liking auto-play Media, There is only solution using Javascript. 

I do agree whole heartedly, but not being an expert in Javascript, setting this up could prove a bit problematic for me.

 

However, what I just cannot understand is that, on another site, it works perfectly, and, setting it up on the current site I am working on, using exactly the same code I used on the other website, it just refuses to work.

Strange, very strange.

Share this post


Link to post
Share on other sites

You only said, Your code works in One Browser but fails in another. So just use Javascript to make it work in the browser where it does not work.

Share this post


Link to post
Share on other sites
3 hours ago, OpaQue said:

You only said, Your code works in One Browser but fails in another. So just use Javascript to make it work in the browser where it does not work.

No, what I said was "My code works in Chrome on one website and will not work on another".

I know that Chrome has disabled autostart of audio and video with sound since April, but other browers still allow it.

Funny enough, I managed to solve it without any Javascript.

The trick was simply to use an iframe and it starts immediately.

Very weird, I must admit.

Thanks for your help anyway.

 

Share this post


Link to post
Share on other sites

Ohh.. sorry, I mis-understood. 

If your code works in one web page and not in another... I m curious what would be the reason?

May be some other code in that page is stopping it from auto-play.

Share this post


Link to post
Share on other sites

I really have not got the slightest clue.

In the page where the code refused to work, there was only some basic HTML, only some paragraphs of text, while the code on the working page was more complicated (including Bootstrap 4 cards and more).

 

It is really a mystery to me too.

 

Share this post


Link to post
Share on other sites

This is really strange as Chrome rolled back those changes in May so maybe it's some left over crud. You should always test with a fresh browser set at defaults as browsers have been implementing user behaviour preferences based on user browsing experiences.

If you read up on Chromium and Chrome developmets, you can see the direction they are heading. The autoplay policy seemed a bit pushed but I do prefer having choice rather than forced to hear things played on my browser unknowingly.

Edited by mastercomputers (see edit history)

Share this post


Link to post
Share on other sites
7 hours ago, mastercomputers said:

Chrome rolled back those changes in May

You're right, probably the changes disappeared from fresh install but could remain on existing installations.

7 hours ago, mastercomputers said:

I do prefer having choice rather than forced to hear things played on my browser unknowingly.

+1. That's why I usually poweroff the speakers on my PC, in order not to hear things I didn't ask.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.