Jump to content

iOS 9.2 Sound broken


kiwi
 Share

Recommended Posts

@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

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 
 
I did a quick test adding this few lines before phaser.js
var 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 ?
 
Link to comment
Share on other sites

  • 2 weeks later...

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

  • 1 month later...
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

  • 1 month later...
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

  • 2 months later...
  • 4 months later...
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

  • 5 weeks later...

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

 Share

  • Recently Browsing   0 members

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