- From: Charlie Roberts <bigbadotis@gmail.com>
- Date: Thu, 3 Oct 2013 13:30:26 -0700
- To: Leonardo Martínez <leolib2004@gmail.com>
- Cc: public-audio-dev@w3.org
- Message-ID: <CAOn5zEhqS8nA7pMtB07GgJNCHr1pEwp61JotU7pQydewL0SyoQ@mail.gmail.com>
Maybe you're already doing this, but In iOS the audio context needs to be created in response to user input. Wrap your initialization code in a function and then do something like this when the page loads: if('ontouchstart' in document.documentElement) { document.getElementsByTagName('body')[0].addEventListener('touchstart', init); }else{ init(); } If you're also running testing Android you'd probably want to do something more sophisticated for the browser sniffing, although the worst that would happen is the sound wouldn't start until the user touches the screen. Make sure you remove the event listener in your init method under iOS. Hope this helps. - Charlie On Thu, Oct 3, 2013 at 7:31 AM, Leonardo Martínez <leolib2004@gmail.com>wrote: > Hello, > > > I have created an app in HTML 5 that generates white noise on its own > using a ScriptProcessorNode (Google Chrome) or a JavaScriptNode (Safari). > > All is working fine for Google Chrome/Safari on my Mac and also in my > Android phone (not to mention that the performance is really bad on my > Xperia Acro S) but it is not working in Safari/Chrome on my iPod Touch 5th > on iOS 6.1.2. > > > > The code is the following for initialization: > > > > window.AudioContext = window.AudioContext || window.webkitAudioContext; > > context = new AudioContext(); > > > > > > if(this.context.createScriptProcessor) > > { > > jsProcessor = context.createScriptProcessor(512, 0, 2); > > alert("Chrome Desktop/Android"); > > } > > else if(this.context.createJavaScriptNode) > > { > > jsProcessor= context.createJavaScriptNode(512,1,1); > > alert("Safari"); > > //adding 1 to node input make it works only for Safari on MAC > > } > > else > > { > > alert("No way"); > > } > > > jsProcessor.onaudioprocess = generateWN; > > gainNode = context.createGainNode(); > > jsProcessor.connect(gainNode); > > gainNode.gain.value = 0.5; > > > > > > I have a button on the screen that when it is touched the gainNode is > connected to context.destination or it's disconnected. I can see that > onaudioprocess event is not triggered on my iPod (iOS 6.1.2 Safari and > Chrome)... > > > > > > What am I doing wrong? Is something different from Safari/Chrome on iOS > than for MAC that I am not considering? > > > > I need to create sound samples on the fly... If this work I would add a > filter node to filter the white noise for generating other sounds as the > user wants. > > > Thanks! > > -- > Leonardo. >
Received on Thursday, 3 October 2013 20:30:54 UTC