• Dear Cerberus X User!

    As we prepare to transition the forum ownership from Mike to Phil (TripleHead GmbH), we need your explicit consent to transfer your user data in accordance with our amended Terms and Rules in order to be compliant with data protection laws.

    Important: If you accept the amended Terms and Rules, you agree to the transfer of your user data to the future forum owner!

    Please read the new Terms and Rules below, check the box to agree, and click "Accept" to continue enjoying your Cerberus X Forum experience. The deadline for consent is April 5, 2024.

    Do not accept the amended Terms and Rules if you do not wish your personal data to be transferred to the future forum owner!

    Accepting ensures:

    - Continued access to your account with a short break for the actual transfer.

    - Retention of your data under the same terms.

    Without consent:

    - You don't have further access to your forum user account.

    - Your account and personal data will be deleted after April 5, 2024.

    - Public posts remain, but usernames indicating real identity will be anonymized. If you disagree with a fictitious name you have the option to contact us so we can find a name that is acceptable to you.

    We hope to keep you in our community and see you on the forum soon!

    All the best

    Your Cerberus X Team

html5 - webaudio bug?

SLotman

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jul 3, 2017
Messages
261
Can anyone please enlighten me?

I have this game: http://icongames.com.br/bocalnaro - music plays fine on Opera and on an old version of Chrome. On latest Firefox (and Palemoon) only sounds will play.

BUT - if I click on another tab, and go back to the game - then music starts playing. What is going on?!
 
Apparently is "media.autoplay" being set to false both on Palemoon and on Firefox blocking the music.

Any hints on how to bypass that? Sounds are playing fine...
 
haha funny game! if you cant figure it out you could always put a browser restriction for now. but there has to be a solution.
 
I *think* the problem is that Monkey/Cerberus is using WebAudio for sounds - but it still uses regular 'html5 audio" for music.

But I don't know WebAudio all that well to the point of reprogramming the html5 target, and keep the music being streamed :/
 
Does that happen locally on your pc too or only when you load it from the server?
 
Ok, I noticed this now under Chrome locally too in my game. But not in the official audio example. Have to check what is different.
 
Ok, I noticed this now under Chrome locally too in my game. But not in the official audio example. Have to check what is different.
Ok, different is that the music in the audioexample plays after a user interaction. In my game right away. If I change that to play after the user presses a button, it works. The browser vendors followed Apple's approach of playing web audio and you need to have some kind of interaction with the browser before you can play a sound now.
 
upload_2018-9-9_12-51-30.png
 
Does that happen locally on your pc too or only when you load it from the server?
Yup.

But... why? The game sounds play fine - just the music that won't.
(And the music only plays after the user press SPACE - or do a mouse click - to start the game...)

Also, you can see in the console its creating a html5 audio object for the music, not webaudio:
(I added a line on mojo.html5.js to dump the created object)

Code:
<audio preload="auto" src="data/sons/show.ogg">

And if there is any doubt, here's the code for PlayMusic:

Code:
gxtkAudio.prototype.PlayMusic=function( path,flags ){
   if( this.musicState ) this.music.pause();
   this.music=new Audio( BBGame.Game().PathToUrl( path ) );
   this.music.loop=(flags&1)!=0;
   this.music.play();
   this.musicState=1;
}

And, html5 audio won't play at all. If I use #HTML5_WEBAUDIO_ENABLED = False, the game remains mute, not even the sounds play.

Even older games I did, that used to work fine, now wont' play music - so i'm guessing browser behaviour changed, completely blocking html5 audio also on desktop (only God knows why...)
http://icongames.com.br/pixuleco/
http://icongames.com.br/cweel/
 
Last edited:
What error do you get inside your browsers console? Similar to mine?

Btw. I got music on Pixuleco.
 
Last edited:
No error, at all :(
Neither Firefox or Palemoon gives any kind of error - they just won't play the music.
 
I don't mean the CX console. I mean the console of your browser in its dev tools.
 
I know.
And it doesn't show anything.

 
Ok, Firefox doesn't show these errors, but I am positive it is the same like with Chrome. You need to have a user input with the mouse or touch, THEN you can play a music file. It is becoming the norm. Apple did it first with their browsers, now the other once fall in line.

The only thing I can look into is your statement, that playing music is not using the newer webaudio. I will get back to you on this.
 
Back
Top Bottom