Sign in to follow this  
lpbr

Android won't play MP3

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!

Share this post


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

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.