kiwi Posted December 9, 2015 Share Posted December 9, 2015 Hi, I just upgraded my iPhone 5s to the latest iOS 9.2 and now all sounds sound broken. I'm using the latest Phaser version thanks san40511 1 Link to comment Share on other sites More sharing options...
kiwi Posted December 10, 2015 Author Share Posted December 10, 2015 Up anyone? Are you experiencing the same issue? Thanks Link to comment Share on other sites More sharing options...
bubamara Posted December 10, 2015 Share Posted December 10, 2015 I'm not using Phaser (Pixi + Howler2 here) : - in Safari, Chrome everything sounds OK- when I run my things from home screen, sound is broken - like heavy undersampled. Not always, but 9 out of 10 times Was OK before iOS 9.2 upgrade... Link to comment Share on other sites More sharing options...
kiwi Posted December 10, 2015 Author Share Posted December 10, 2015 I forgot to mention that I run the game inside a wkwebview. Using safari on home screen everything works fine Link to comment Share on other sites More sharing options...
bubamara Posted December 10, 2015 Share Posted December 10, 2015 @kiwi can you try to run another game from home screen and then opening first one ? When I close all running apps from task manager, sound is OK. But once there is something running in the background (something that is using webAudio?), sound is broken.I've tried to change file's sample rate, bitrate - all without success. Link to comment Share on other sites More sharing options...
kiwi Posted December 10, 2015 Author Share Posted December 10, 2015 Game works fine from home screen. Issue is from inside a native wrapper Link to comment Share on other sites More sharing options...
nicof Posted December 15, 2015 Share Posted December 15, 2015 I also experience a similar issue on ios 9.2 using cordova and wkwebview.I'd say 9/10 as well the sound is really distorted.I haven't tried with other versions of ios yet. But seems ios 9 suffers from few problems http://www.holovaty.com/writing/ios9-web-audio/ Going to investigate this when I'll have time. So far I'm sure it's related to webAudio since disabling it window.PhaserGlobal = { disableWebAudio: true };produces a clean sound all the time Update Ok seems I found a fix. And I think this code should be integrated in phaserjs this guy managed to figure out a solution for IOS 9.2 https://github.com/Jam3/ios-safe-audio-context/blob/master/index.js I did a quick test adding this few lines before phaser.jsvar AudioCtor = window.AudioContext || window.webkitAudioContext; window.webkitAudioContext = function createAudioContext (desiredSampleRate) { desiredSampleRate = typeof desiredSampleRate === 'number' ? desiredSampleRate : 44100 var context = new AudioCtor() // Check if hack is necessary. Only occurs in iOS6+ devices // and only when you first boot the iPhone, or play a audio/video // with a different sample rate if (/(iPhone|iPad)/i.test(navigator.userAgent) && context.sampleRate !== desiredSampleRate) { var buffer = context.createBuffer(1, 1, desiredSampleRate) var dummy = context.createBufferSource() dummy.buffer = buffer dummy.connect(context.destination) dummy.start(0) dummy.disconnect() context.close() // dispose old context context = new AudioCtor() } return context }; It's a dirty monkey patch It's not tested with other ios versions inferior to 9.2 but it has fixed the distorsion issue in my game. (I use an mp3 generated audiosprite, stereo, 44100) According to the README on github it should work with ios 6+ It's kinda tricky to patch this with the current phaserjs implementation since the old context has to be disposed (it will means to update all the context, gainNode etc on touch unlock with the current implementation). Does it solve your issue as well guys ? staff0rd 1 Link to comment Share on other sites More sharing options...
JMD Posted December 24, 2015 Share Posted December 24, 2015 I'm still having this issue. In fact, none of the audio from Phaser works (using MP3's) and no `new Audio()` calls made in my JS works at all. Tested on iOS 9, iOS 9.2 with an iPad Air 2, iPhone 6. Has anyone found a different solution? The webkitAudioContext one hasn't done justice for me (yet!). Edit: After surfing the net/Github, it's apparent iOS 9/WebKit had a bug with the touchstart event. If I tap the game scene (canvas) all the sounds come to life. If I start dragging, which ironically is the first method of game mechanics I'm using, no sounds work. Cheers. Link to comment Share on other sites More sharing options...
staff0rd Posted February 9, 2016 Share Posted February 9, 2016 On 12/15/2015 at 8:51 AM, nicof said: Does it solve your issue as well guys ? Thanks for that post - it seems this was my issue too. Rather than patch phaser I used the code in that snippet to setup the AudioContext prior to loading Phaser: window.PhaserGlobal = { audioContext: createAudioContext(44100) }; Link to comment Share on other sites More sharing options...
nicof Posted February 9, 2016 Share Posted February 9, 2016 1 hour ago, staff0rd said: Thanks for that post - it seems this was my issue too. Rather than patch phaser I used the code in that snippet to setup the AudioContext prior to loading Phaser: window.PhaserGlobal = { audioContext: createAudioContext(44100) }; This is definitely a cleaner solution. Link to comment Share on other sites More sharing options...
admyral Posted March 10, 2016 Share Posted March 10, 2016 On 2/9/2016 at 4:43 PM, staff0rd said: Thanks for that post - it seems this was my issue too. Rather than patch phaser I used the code in that snippet to setup the AudioContext prior to loading Phaser: window.PhaserGlobal = { audioContext: createAudioContext(44100) }; This workaround isn't working for me. Even if the sample rate is set to 44100 on my iOS device (9.2.1). Currently using the following on iOS: window.PhaserGlobal = { disableWebAudio: true }; However this increases the load time substantially. Is anyone else having this issue on iOS? Link to comment Share on other sites More sharing options...
san40511 Posted May 17, 2016 Share Posted May 17, 2016 Hi guys. Do somebody resolve this problem? I have the same problem but on ios 9.3 and only on 32x processors. Strange... very strange Link to comment Share on other sites More sharing options...
kosmoskolio Posted October 4, 2016 Share Posted October 4, 2016 On December 24, 2015 at 11:30 AM, JMD said: I'm still having this issue. In fact, none of the audio from Phaser works (using MP3's) and no `new Audio()` calls made in my JS works at all. Tested on iOS 9, iOS 9.2 with an iPad Air 2, iPhone 6. Has anyone found a different solution? The webkitAudioContext one hasn't done justice for me (yet!). Edit: After surfing the net/Github, it's apparent iOS 9/WebKit had a bug with the touchstart event. If I tap the game scene (canvas) all the sounds come to life. If I start dragging, which ironically is the first method of game mechanics I'm using, no sounds work. Cheers. I had the same issue - my game starts with dragging mechanics which would not initiate the sound on iOS safari. I decided to try some of the official Phaser tutorials and it turned out this one: http://phaser.io/examples/v2/audio/sound-complete works fine with dragging. After looking around the code I found that this works for me: game.sound.setDecodedCallback([dummySound], enableSound, this); function enableSound() { function enableTheSound() { dummySound.play(); }; console.log("ready"); game.input.onDown.addOnce(enableTheSound, this); } This will play a dummy (silent) sound file on the first touch of the screen which will enable the sounds. It might not be a good decision but it worked for me as I did not have to change any other code in my game Hope I've helped Link to comment Share on other sites More sharing options...
Kranzky Posted November 4, 2016 Share Posted November 4, 2016 I've recently hacked up this: https://github.com/jasonhutchens/nosedive You can run it here: http://nosedive.kranzky.com/ Sound works on Android, but not iOS 10, even though the tutorial cited above does work: http://phaser.io/examples/v2/audio/sound-complete Anyone care to look to help me figure out what I'm doing wrong? Audio is loaded here: https://github.com/jasonhutchens/nosedive/blob/master/src/states/Load.js and is played here: https://github.com/jasonhutchens/nosedive/blob/master/src/states/Done.js Thank! Link to comment Share on other sites More sharing options...
Recommended Posts