iPad weirdness with multiple sounds

  • Problem
  • Updated 5 years ago
  • Acknowledged
Hi,
I'm trying to load a bunch of short mp3-encoded sounds (1-2 seconds) and trigger them from mouse/touch events in a canvas. It works fine with the flash player, but I've noticed some weird stuff happening on the iPad. The first sound usually plays fine, but then the second sound is dropped, or loops, or is delayed. I realise HTML5 support is newish, so I pared the code back to plain Javascript (ie. without SoundManager) to try and figure out exactly what was happening. This test code contains just two sounds, which are triggered from button events.

http://stewartgreenhill.com/test/audi...

On Safari/OSX it works fine, although Safari does not dispatch 'playing' events after a sound has been played once.

On the iPad, the sounds play OK, but when switching between sounds it seems to fail its first attempt to play a new sound. That is, if I play:
A A B B A B A A
I get:
A A [silent] B [silent] [silent] [silent] A
The 'ended' event is dispatched immediately after the 'playing' event, as if the sound has zero duration. Like desktop Safari, it doesn't dispatch 'playing' once a sound has been played the first time.

Has anyone else noticed problems like this on the iPad? It looks like an Apple bug rather than a problem with SoundManager, but I'm a noob at Javascript so am wondering if there are workarounds for this.

Cheers,
Stewart
Photo of stewart.greenhillS

stewart.greenhill

  • 3 Posts
  • 0 Reply Likes
  • confused

Posted 5 years ago

  • 1
Photo of Scott

Scott, Official Rep

  • 3807 Posts
  • 245 Reply Likes
Official Response
This is a weird one, which I attribute to the "magical" behaviour of the iPad (and Safari on the desktop) - where by "magical", I mean buggy and/or annoying. ;)

From what I understand, the iPad and iPhone (iOS4 - currently 3.2 for iPad, 4.0 for iPhone) will not play a sequence of sounds unless a) the sound is initiated by the user eg., clicking a link leading to a play() call, and b) the second sound must be started from the onfinish() event of the first. With the first round of HTML5 audio support, this did not work in SM2 as I hadn't sorted out the iPhone/iPad behaviour - but "chaining" should work as of the 20100822 version, eg. the "Muxtape-style" demos on the homepage will play in sequence without further "clicking" after the first item has been tapped.

It may be with the iPad that the "short sounds" issue exists; I have not thoroughly tested this, but desktop Safari is known to have some problems. I have seen weird looping issues with the "bc quail" test sound on the SM2 homepage using the iPad as well, which I'm at a loss to explain. I suspect it's another bug.

Apple are aware of the issues with desktop Safari, and there are problems with loading sounds in general on the desktop under Snow Leopard, specifically (ironically, Safari on Windows seems to be OK.) More detail can be found with bugs.webkit.org #32159 if you're interested.

Unfortunately the issue lies primarily with Apple at this time to the best of my knowledge; I'm hoping a software/firmware update will fix these things in the near future.