lamyty Posted June 4, 2017 Share Posted June 4, 2017 Hello guys, as the headline suggests i got a problem to play sounds in the Firefox browser. I start the sound using the Phaser function sound.play(). This works in every popular browser for me except for firefox. There is no error in the console and the sound.isPlaying function returns true, but i got no sound at all. I also tryied different mp3 files to check if my original file is corrupted but that doesn´t seams to be the case. Any other mp3 file also dont play. If you had any suggestions for me what could be wrong i would be really happy! Here is my code: function preload() { /*----- Audio ----- */ game.load.audio('title', 'sounds/title.mp3'); game.load.audio('test', 'sounds/dHb_The_Riddle.mp3'); /*----- Audio ----- */ /*----- Hintergrund Assets ----- */ game.load.atlas('background', 'assets/dungeon/prod/background_animated/background_animated_sheet.png', 'assets/dungeon/prod/background_animated/background_animated_sheet.json'); /*----- Hintergrund Assets----- */ /*----- Player Assets----- */ game.load.atlas('char', 'assets/char/char_atlas.png', 'assets/char/char_atlas.json'); /*----- Player Assets----- */ }; /*----- Globale Variablen ----- */ var player; var background_animated; var cursors; var platforms; var ground; var titlesfx /*----- Globale Variablen ----- */ function create() { /*----- Allgemeine Einstellungen ----- */ // Vortlaufen des Gameloops bei Verlust des Fokus game.stage.disableVisibilityChange = true; /*----- Allgemeine Einstellungen ----- */ /*----- GAME PHYSICS ----- */ // Starten der GamePhysics (Arcade) game.physics.startSystem(Phaser.Physics.ARCADE); /*----- GAME PHYSICS ----- */ /*----- Gruppen (Collider) ----- */ // Gruppe für alle Physischen Hindernisse platforms = game.add.group(); // Hinzufügen der Physics für Gruppe "platforms" platforms.enableBody = true; /*----- Gruppen (Collider) ----- */ /*----- Audio ----- */ titlesfx = game.add.audio('test'); /*----- Audio ----- */ /*----- Sprites ----- */ // Hintergrund background_animated = game.add.sprite(0,0, 'background'); // Boden ground = platforms.create(0, game.world.height - 35, ''); // Player player = game.add.sprite(0, game.world.height - 84, 'char'); /*----- Sprites ----- */ /*----- GameWorld conf ----- */ // Erstellen der Hintergrundanimation background_animated.animations.add('frame', Phaser.Animation.generateFrameNames('frame', 1, 8), 10, true); // Scalieren des Bodens ground.scale.x = game.world.width; ground.scale.y = 35; // Fixieren des Bodens ground.body.immovable = true; /*----- GameWorld conf. ----- */ /*----- Player conf. ----- */ // Physics game.physics.arcade.enable(player); player.body.bounce.y = 0; player.body.gravity.y = 300; player.body.collideWorldBounds = true; // Player Animationen player.animations.add('walkLeft', Phaser.Animation.generateFrameNames('walkLeft', 1, 9), 8, true); player.animations.add('walkRight', Phaser.Animation.generateFrameNames('walkRight', 1, 9), 8, true); player.animations.add('walkDown', Phaser.Animation.generateFrameNames('walkDown', 1, 9), 8, true); player.animations.add('walkUp', Phaser.Animation.generateFrameNames('walkUp', 1, 9), 8, true); player.animations.add('slashDown', Phaser.Animation.generateFrameNames('slashDown', 1, 6), 20, true); /*----- Player conf. ----- */ /*----- Movement ----- */ /* Modifizierter Phaser Controller erweitert um: 1. walkLeft 'A' 2. walkRight 'D' 3. walkUp 'W' 4. walkDown 'S' 5. slashDown 'SPACEBAR' */ cursors = game.input.keyboard.createCursorKeys(); /*----- Movement ----- */ }; function update() { if (titlesfx.isDecoded == true && titlesfx.isPlaying == false){ titlesfx.play(); } /*----- Hintergrund ----- */ // Starten der Hintergrundanimation background_animated.animations.play('frame'); /*----- Hintergrund ----- */ /*----- Collision Handling ----- */ // Prüft auf Kollisionen für alle Member der Gruppe "platforms" für den Player var hitPlatform = game.physics.arcade.collide(player, platforms); /*----- Collision Handling ----- */ /*----- Player Controlls ----- */ // Horizontale Geschwindigkeit zurücksetzen (x / frame) player.body.velocity.x = 0; // Horizontale Geschwindigkeit zurücksetzen (y / frame) player.body.velocity.y = 0; // Player Movement & Animationen if (cursors.walkUp.isDown) { player.body.velocity.y = -150; player.animations.play('walkUp') } else if (cursors.walkDown.isDown) { player.body.velocity.y = 150; player.animations.play('walkDown'); } else if (cursors.walkLeft.isDown) { player.body.velocity.x = -150; player.animations.play('walkLeft'); } else if(cursors.walkRight.isDown) { player.body.velocity.x = 150; player.animations.play('walkRight'); } else if (cursors.slashSpace.isDown) { player.animations.play('slashDown'); } else { player.animations.stop(); player.frame = 1; } }; /*----- Player Controlls ----- */ Link to comment Share on other sites More sharing options...
squilibob Posted June 9, 2017 Share Posted June 9, 2017 Are you running phaser off of localhost? Link to comment Share on other sites More sharing options...
lamyty Posted June 9, 2017 Author Share Posted June 9, 2017 Hay, thanks for your reply. I was running Phaser from apache2. The problem has solved itseld by just reboot my machine. Dont know what exactly was wrong but everything works fine now! Link to comment Share on other sites More sharing options...
Recommended Posts