jonwiesman Posted September 16, 2017 Share Posted September 16, 2017 Hi, I'm trying to play a simple .m4a file when the user collides with an object. I create it like this: game.load.audio("dot0", "sounds/dot0.m4a"); sfxDot = game.add.audio("dot0"); Then later, try to play it like this: sfxDot.play(); But I get the following error: Cannot read property 'createBufferSource' of null at c.Sound.play (phaser.min.js:3) at Object.collectDot ( The sfxDot object seems like a valid sound, from the F12 console: c.Sound {game: c.Game, name: "dot0", key: "dot0", loop: false, markers: {…}, … I'm sure I'm doing something stupid, this is my first attempt to get a sound to play so I'm probably just missing out on a setup call or something. Also, I'm not even sure that .m4a files are supported, but they were listed in the docs. I looked through the audio samples but couldn't really find a sample that wanted to do exactly what I'm doing here (open a .m4a and play it.) Link to comment Share on other sites More sharing options...
jonwiesman Posted September 16, 2017 Author Share Posted September 16, 2017 Never mind I found the problem! I needed to have my call to game.add.audio execute after game.load.audio had finished its loading. I just put the add.audio call in the game state after the load state had finished its work. Link to comment Share on other sites More sharing options...
Recommended Posts