Recommended Posts

Hi all

 

I'm finishing up a little game and just now I found out that Safari is not so friendly with audio.

I have tested my game working fine on the following browsers: chrome, firefox, IE, chrome android, and chrome ipad.

I tested my game on Ipad 2's safari, but it says "error loading asset from URL null (no supported audio URL specified)"

TypeError: 'null' is not an object (evaluating 'this.context.createGain')

TypeError: 'undefined' is not an object (evaluating 'this.masterGain.gain')

 

Tested on my PC's safari, the erorr is the same.

 

My audio spec is

- mp3 96kbps 22,050 kHz

- fallback to ogg 96kbps 22,050 kHz

 

Can anyone please give me some clue how to fix this?

 

Thanks!

Share this post


Link to post
Share on other sites

I just tested m4a files. No luck either. I keep getting the same error loading asset from URL null

 

Here's a portion of my preload code

preload: function () {	// load assets for the loading screen	this.preloaderBar = this.add.sprite(this.game.world.centerX - 150,this.game.world.centerY, 'preloaderBar');    	this.load.onLoadComplete.addOnce(this.onLoadComplete, this);    	this.load.setPreloadSprite(this.preloaderBar);        	// Begin load here    	this.game.load.bitmapFont('littera', 'assets/fonts/littera.png', 'assets/fonts/littera.xml');    	this.load.image('mainmenu_bg', 'assets/mainmenu/mainmenu_bg.jpg');    	this.load.atlas('mainmenu_atlas', 'assets/mainmenu/mainmenu_atlas.png', 'assets/mainmenu/mainmenu_atlas.json');        // AUDIO        this.game.load.audio('bgm_menu', ['assets/audio/bgm_mainmenu.m4a', 'assets/audio/bgm_mainmenu.ogg']);}

The game works perfectly fine on desktop and a couple of android devices (just managed to grab and test on some).

 

I'm beginning to think that it's an issue from iOS itself: https://paulbakaus.com/tutorials/html5/web-audio-on-ios/

But this is 2015 and I think Phaser is using web audio. In worst case, audio on iOS should be loaded perfectly and muted by default until user interaction.

 

Is there anything else that I can try?

Share this post


Link to post
Share on other sites

Hi

 

My code is pretty standard; it works well on Chrome and Firefox, even on Android's stock browser

 

Here's the log from Safari

audio[bgm_menu]: error loading asset from URL null (no supported audio URL specified)

audio[bgm_game]: error loading asset from URL null (no supported audio URL specified)

 

Followed by

TypeError: 'null' is not an object (evaluating 'this.context.createGain')

TypeError: 'undefined' is not an object (evaluating 'this.masterGain.gain')

 

Fthese above I think is because the game tried to play a sound that is not properly loaded

Actually looking at the console log, all sound files are not loaded on Safari

 

What is your audio file's quality (kbps, khz)? That might be the issue here?

Share this post


Link to post
Share on other sites

I figured there is something wrong with my audio files so I tried

- converting them to 128kbps 44100hz, no luck

- try importing a mp3 sound that comes with the phaser sample, not working either

- updating from phaser 2.3.0 to the latest 2.4.2, nope

 

The game is working perfectly fine on mobile / desktop, only on browsers other than safari

It seems like safari is handling this audio loading stuff differently than other browsers. At least to me, that seems to be the case.

 

I'm using firebug lite to show console on my ipad http://iosbookmarklets.com/tutorials/firebug-lite-bookmarklet/

And from there I see that the requests to load audio files fail. Loading json, xml worked great

 

Problem could be this, but I'm not sure if it is and how to fix this http://stackoverflow.com/questions/1995589/html5-audio-safari-live-broadcast-vs-not

 

This would be the perfect time for Richard to show up and show me some light. Kinda desperate here now :(

Share this post


Link to post
Share on other sites

I had this problem too. No format worked on Ipad Safari. Then looked through phaser examples and only one of them worked. The solution is to have the first sound play on a button click. No other inputdown etc works.

 

var button = game.add.button(x, y, 'button', click, this, 0, 1, 2);

 

Click function would play the first sound. After this other sounds work as expected.

 

Make this your start game button etc. 

 

This is an apple security etc stupid feature that requires human interaction to start playing sounds.

 

m4a worked as format.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.