Jump to content

Failed to execute 'decodeAudioData' on 'AudioContext'


facetiousfactorial.cs
 Share

Recommended Posts

I've followed the directions on photonstorm's website the best i could to play audio whenever the world restarts. (This is a mod of a flappy bird project). the console reads:

Phaser.StateManager - No state found with the key: main_state phaser.min.js:4Uncaught SyntaxError: Failed to execute 'decodeAudioData' on 'AudioContext': invalid ArrayBuffer for audioData. phaser.min.js:10

My main.js:

/*jslint node: true */"use strict";var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');var sfx = Phaser.Sound;var main_state = {		preload: function () {        this.game.stage.backgroundColor = '#71c5cf';        this.game.load.image('george', 'assets/george.png');        this.game.load.image('pipe', 'assets/pipe.png');		this.game.load.audio('sfx', 'assets/music.mp3');    },   	    create: function () {				/*AUDIO*/		var sfx = game.add.audio('sfx');				/*SPRITES & MECHANICS*/		this.george = this.game.add.sprite(100, 245, 'george');        this.george.body.gravity.y = 1000;        var space_key = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);        space_key.onDown.add(this.jump, this);        this.pipes = game.add.group();        this.pipes.createMultiple(20, 'pipe');        this.timer = this.game.time.events.loop(1500, this.add_row_of_pipes, this);					this.score = -1;        var style = { font: "30px Arial", fill: "#ffffff" };        this.label_score = this.game.add.text(20, 20, "Score = 0", style);				this.game.state.start('main_state');    },        update: function () {		if (this.george.inWorld === false){        	this.restart_game();		}		        this.game.physics.overlap(this.george, this.pipes, this.restart_game, null, this);	},      jump: function () {        this.george.body.velocity.y = -350;    },    restart_game: function () {        this.game.time.events.remove(this.timer);        this.game.state.start('main');		sfx.play();    },    add_one_pipe: function (x, y) {        var pipe = this.pipes.getFirstDead();        pipe.reset(x, y);        pipe.body.velocity.x = -200;        pipe.outOfBoundsKill = true;    },    add_row_of_pipes: function () {        var hole = Math.floor(Math.random() * 5) + 1;                for (var i = 0; i < 8; i++){            if (i != hole && i != hole +1)                this.add_one_pipe(400, i*60+10);		}		        this.score += 1;        this.label_score.content = 'Score = ' + this.score;    },};game.state.add('main', main_state);game.state.start('main');
Link to comment
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...
 Share

  • Recently Browsing   0 members

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