haden Posted September 1, 2013 Share Posted September 1, 2013 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 More sharing options...
haden Posted September 1, 2013 Author Share Posted September 1, 2013 I finally got the sounds working in my game, which is better Link to comment Share on other sites More sharing options...
rich Posted September 1, 2013 Share Posted September 1, 2013 My favourite kinds of problems are ones that have been solved by the time I read them Speakeasys, haden, Qqwy and 1 other 4 Link to comment Share on other sites More sharing options...
MikeHart Posted September 1, 2013 Share Posted September 1, 2013 How did you got it working? Link to comment Share on other sites More sharing options...
haden Posted September 1, 2013 Author Share Posted September 1, 2013 I just used the code from the example into my game, and it worked. Although I noticed that calling Sound.play() should be inside an event handler, in my case it's onTap or onDragStop. Link to comment Share on other sites More sharing options...
rich Posted September 2, 2013 Share Posted September 2, 2013 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 More sharing options...
haden Posted September 2, 2013 Author Share Posted September 2, 2013 Didn't work, calling music.play() inside create() doesn't start the music !!! what are you using to create the audio spritesheet ? Link to comment Share on other sites More sharing options...
haden Posted September 4, 2013 Author Share Posted September 4, 2013 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: falseFurthermore, 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 More sharing options...
rich Posted September 4, 2013 Share Posted September 4, 2013 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 More sharing options...
haden Posted September 4, 2013 Author Share Posted September 4, 2013 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 More sharing options...
rich Posted September 10, 2013 Share Posted September 10, 2013 Just to say that I've fixed this in the 1.00JS branch So now you can start a piece of music playing and as soon as the device becomes touch unlocked it will begin playback properly. haden 1 Link to comment Share on other sites More sharing options...
haden Posted September 10, 2013 Author Share Posted September 10, 2013 Really cool, I will be using 1.00JS for my next game Link to comment Share on other sites More sharing options...
Recommended Posts