Jump to content

Safari and problem with sound


flogvit
 Share

Recommended Posts

I have a strange problem with the sound (tried Phaser 2.3.0 and Phaser 2.4.4)

 

I do the loading of sound in preloading as

this.load.audio('music', 'assets/music/freefreddy_mixdown.mp3');

and I start the sound with something like

game.music = game.add.audio('music', 1, true);game.music.play();

I also have sounds which should be played. This works fine in all other browsers than Safari.

 

But in Safari, it works strange

 

If I start a vanilla Safari and type in the url (web or localhost:9000) it will load the game, but in the resource tab in Safari debug it will not show any XHRs directory (which includes all the .mp3 files). Now it will not play any sounds. But if I do a refresh on the page (cmd-r or enter in url), it will load the XHRs and play the sounds fine.

 

I've tried the button approach where the splash screen, or the boot screen, have a button, but this doesn't work. Same problem with no XHRs directory in resources.

 

When I check the SoundManager, console.log(game.sound), I see a difference. With reload, I get

 

SoundManager._sounds[1].Sound.context[webkitudioContext].state = "running"

 

without the reload this is set to "suspended".

 

Anyone else seen this?

Link to comment
Share on other sites

Well, after struggling with this for a long time, and posted this question, I thought I should try to reload the SoundManager. It seems this works well. So now I do in boot:

init: {   this.game.sound.boot();}

and that starts the sound, even though it doesn't show the XHRs in the resource list.

 

btw, I need to wait until init in first state to do the boot, or else it doesn't work.

Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...
On 8 January 2016 at 1:22 AM, flogvit said:

Well, after struggling with this for a long time, and posted this question, I thought I should try to reload the SoundManager. It seems this works well. So now I do in boot:


init: {   this.game.sound.boot();}

and that starts the sound, even though it doesn't show the XHRs in the resource list.

 

btw, I need to wait until init in first state to do the boot, or else it doesn't work.

I searched and tried everything, even tried to refresh page but nothing worked except this. Thank you!

By the way how it's possible that only we've encountered this problem? Even Rich didn't mention anything about that?? 

Link to comment
Share on other sites

  • 3 months later...
  • 3 weeks later...

Thanks a lot. I just noticed that I had the same problem. The 1st load of the game on local server prevents the game from playing any sound at all when I open the game in the Desktop Safari browser (Version 9.1.3) on El Capitan (OSX 10.11.6). It plays normally only after I hit the reload button of the browser.

I am using Phaser v2.6.1 for my game.

game.sound.boot(); right after a loop for load.audio() sorted out. My game is playing sound normally from the 1st loading.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...