Jump to content

How to use SoundManager?


cucumber
 Share

Recommended Posts

I want be able to change volume for all sounds and turn off all sound. I guess SoundManager is for this. But I  can't find a way to use it properly.

 

game.SoundManager.pauseAll()

or

var sm = new Phaser.SoundManager(game);

sm.pauseAll()

does not work.

 

Please provide some examples.

Link to comment
Share on other sites

I need to know duration before playing sound and I found this weird solution :)

 

sfx = game.add.audio('sfx');
sfx.onPlay.add(function(s){
  s.stop();
  s.onPlay.removeAll();
  console.log(s.duration);
  //s.play(null,s.duration/2);

});
sfx.play();

 

I'll wrap it in a function.

Link to comment
Share on other sites

But it didn't solve my problems. My Oggs and Mp3s have different durations :( because of gaps.
I guess i have to make single file and use markers.
I'm going to try this utility https://npmjs.org/package/audiosprite

And also I heard about sound sprites in phaser from this topic http://www.html5gamedevs.com/topic/2962-sound-sprites/
Is there an example how to use them?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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