Sign in to follow this  
Simonnice

Problem with playing audio in Firefox

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')

 

Share this post


Link to post
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(…).

Share this post


Link to post
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.

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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.