W3C home > Mailing lists > Public > public-audio@w3.org > October to December 2012

iOS 6 context "activation" requirement

From: Joseph Berkovitz <joe@noteflight.com>
Date: Mon, 5 Nov 2012 09:45:32 -0500
Message-Id: <EB1BCB89-D9E6-443B-88F7-743BB75666C9@noteflight.com>
To: "public-audio@w3.org Group" <public-audio@w3.org>
Speaking of "currentTime" not increasing… In iOS6 WebKit: not only does a node need to be added to the context for the time to advance, but this addition must initially take place in a thread triggered by some user-initiated event. Otherwise the time doesn't advance and no audio output occurs. I assume this is due to iOS6's attempt to prevent audio "spamming" by web pages.  It probably relates to Jer Noble's question of 2/28/2012:

> 	• Should an AudioContext be allowed to play without being initiated with a user gesture?
> 


What is the status of the current iOS 6 behavior -- is it a proposed addition to the spec? A bug? An undocumented vendor modification?

I'm not presently arguing for a specific policy. However, the present approach on iOS does require a tricky workaround when audio output is both user-initiated *and* asynchronous (e.g. user interacts with game, 1 second later a sound effect occurs). In our application we have had to immediately play a silent sound in the context on the first user interaction, in order to permit later asynchronous sounds to be played.

Both the behavior and the workaround aren't all that obvious and I burned a bunch of time trying to figure out why the API sometimes worked and sometimes didn't. If that's going to be the recommended practice, I'd love to get the issue resolved and any consequent changes published in the spec.  (Admission: I haven't looked through Apple's iOS 6 docs to see if this behavior was documented there.)

…Joe

> On Sun, Nov 4, 2012 at 4:55 PM, Srikumar Karaikudi Subramanian <srikumarks@gmail.com> wrote:
> The "currentTime" property stays at 0 for a brief period in the webkit implementation. This is most prominent on iOS6 where it can take up to 6 seconds for currentTime to begin updating. The way I work around this is to wait using setTimeout until currentTime becomes > 0 before doing anything else. On PCs, this time is negligible in most cases, but shows up as multiple sounds getting triggered simultaneously on the rare occasion if the page starts playing sounds at or close to load time (it is difficult to get a reproducible case). 
Received on Monday, 5 November 2012 14:45:55 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:50:03 UTC