Jump to content

Android won't play MP3


lpbr
 Share

Recommended Posts

I just ran into another issue with Phaser and I'd like to know if it's a known bug – and of course if there is a solution!

I am trying to play sounds (mp3) with no success. The sound plays fine on my computer using Windows browser but the same code won't produce any sound on Opera Mobile Emulator or on my actual mobile (Samsung J2). I didn't try 'ogg' format because I searched online and found other people with the same problem and that have actually tried with no success.

After several frustrated tests with my own code I tried the following Phaser examples:

https://phaser.io/examples/v2/audio/loop

https://phaser.io/examples/v2/audio/play-music

Guess what... same issue: works on computer but not on Opera Emulator neither my mobile.

Since I am writing this code specifically for mobiles this is a MUST for me that sounds play on them. Any clue? Below my code...

var game = new Phaser.Game(window.innerWidth, window.innerHeight, Phaser.AUTO, 'test', { preload: preload, create: create });

var aExtensions = [

];
var aExtensions = ['.png','.mp3'];
var aTypes = ['img','snd'];
var aAssets = ['door','knock'];

function preload() {
    game.load.image(aAssets[0],aTypes[0]+'/'+aAssets[0]+aExtensions[0]);
    game.load.audio(aAssets[1],aTypes[1]+'/'+aAssets[1]+aExtensions[1]);
}

function create() {
    var gamegroup = game.add.group();
    gamegroup.inputEnableChildren = true;

    window[aAssets[0]] = gamegroup.create(0,0, aAssets[0]);
    window[aAssets[1]+'snd']= game.add.audio(aAssets[1]);
    window[aAssets[0]].inputEnabled = true;

    window['lst'+aAssets[0]] = function (me) {
	knocksnd.play();
	me.visible = false;
    }
    window[aAssets[0]].events.onInputUp.add(window['lst'+aAssets[0]], this);
}

Thanks!

Link to comment
Share on other sites

Never mind... after a LOT of research and more tests I figured that it's a Chrome bug. It works perfectly on Opera. One whole day of work lost thanks to a stupid browser that doesn't work as it should.

:angry:

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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