Jump to content

Problem with playing audio in Firefox


Simonnice
 Share

Recommended Posts

Hello there! I'm currently working on an endless runner, and it is going well so far! Today I've encountered a slight problem concerning the audio of my characters attack-animation, specifically when playing the game on Firefox.

When I'm on Chrome it works just as it should, but on Firefox it sounds like the sound repeats itself several times during the animation, making a really weird noise. I don't really understand what is causing the problem, but it seems like some kind of update problem, maybe that Firefox is refreshing faster than Chrome or something like that.

Here are the relevant code snippets: 

 // Adding attack sound
    this.attackSound = this.add.audio('attackSound')
    this.attackSound.volume = 0.3

 

if (this.cursors.right.downDuration(140)) {
        this.knight.play('attacking')
        this.attackSound.play()
        this.enableHitBox()
        this.time.events.add(Phaser.Timer.SECOND * 0.3, this.disableAllHitboxes, this)
      }

 

As I said, it works perfectly on Chrome, and the background music I'm looping works perfectly in both browsers. I load in the sound file like this:

 this.load.audio('attackSound', 'assets/audio/attack2.mp3', 'assets/audio/attack2.ogg')

 

Link to comment
Share on other sites

8 hours ago, Simonnice said:

When I'm on Chrome it works just as it should, but on Firefox it sounds like the sound repeats itself several times during the animation, making a really weird noise.

Could be the sound is is being started several times in quick succession.

Check that sound with debug.soundInfo(…).

Link to comment
Share on other sites

Ran the debugger in both Chrome and Firefox, and there are some notable differences. The duration of the sound is longer on Firefox 457ms vs 377 on Chrome, and it also seems that the audio playback is a bit erratic on Firefox. In Chrome, the time counter for the sound is counted up in a very consistent manner, but in Firefox it sometimes just goes from time 0 to 456 in an instant. It does seem like there is some kind of repeating going on in the Firefox browser for some reason.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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