Jump to content

Audio example in Phaser 1.00TS083


haden
 Share

Recommended Posts

I am trying to run the example "play sound 1" from Phaser 1.00TS083 Tests/audio, but it doesn't seem to work on mobile. On my iPod touch 4th gen with iOS 6.1.3, when running the example, the sound doesn't play when pressing the button and the browser crashes after a few seconds.

Should this test be running on my iPod touch ?

Link to comment
Share on other sites

It shouldn't need to be in an event handler. When my game boots I load the audio in the preloader, then do this:

        music = game.add.audio('music');        music.override = true;        music.addMarker('map', 1, 34, 1, true);        music.addMarker('help', 35, 45);        music.addMarker('puzzle1', 47, 77, 1, true);        music.addMarker('puzzle2', 78, 104, 1, true);        music.addMarker('puzzle3', 105, 131, 1, true);        music.addMarker('success', 132, 138);        music.addMarker('laugh', 139, 141);        music.addMarker('unlocked', 142, 145);        music.addMarker('detected', 146, 154);        music.addMarker('eloas', 155, 157);        music.addMarker('growl', 158, 162);        music.addMarker('title', 163, 194, 1, true);

Which is a audio sprite with lots of music markers in it. Then I just do:

            music.play(marker);
Link to comment
Share on other sites

Here a small example I am using to test Phaser audio:

(function () {    var game = new Phaser.Game(this, 'game', 320, 480, preload, create, null, render);    var sfx:Phaser.Sound;    function preload() {        game.load.audio('sfx', ['win-snd.mp3']);    }    function create() {        sfx = game.add.audio('sfx');        sfx.play('');    }    function render() {        Phaser.DebugUtils.renderSoundInfo(sfx, 10, 20);    }})();

on my desktop, it runs just fine, starting the sound as soon as the game starts.

On my iPod touch 4th gen and iPad 2 (both using Safari, iOS 6.1.3), the sound doesn't start, and the displayed debug information is :

Sound: sfx Locked: true Pending Playback: trueDecoded: true Decoding: falseTotal Duration: 0 Playing: falseTime: 0Volume: 1 Muted: falseWebAudio: true Audio: false

Furthermore, on my LG-P705 (Android 4.0.3) the sound does start playing correctly, but the debug information shows "NaN" in Total Duration, and Time just keeps increasing, it's like the sound doesn't stop playing.

 

am I doing anything wrong ?

Link to comment
Share on other sites

This is exactly how it should work. You cannot play sounds on iOS without the user first touching the device - hence the "locked" flag being set to true. When the SoundManager starts up it will hook itself into the InputManager and steal the first touch event you give it, at that point only can it play the sound.

 

The Android NaN issue sounds like something else though, will have a look here.

Link to comment
Share on other sites

This is exactly how it should work. You cannot play sounds on iOS without the user first touching the device - hence the "locked" flag being set to true. When the SoundManager starts up it will hook itself into the InputManager and steal the first touch event you give it, at that point only can it play the sound.

Yet it doesn't start playing the sound when I touch the screen. The sound Locked state becomes true, but it's stays in Pending Playback.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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