3

I found this link to a page here on StackOverflow about "Creating Audio using Javascript in <audio>", and this page on how to play audio on multiple channels. I found that the iPhone supports the audio tag and the Audio object in Javascript to play single channel audio, but is there a way to play audio on multiple channels?

Maybe I'm over complicating this, so this is what I'm trying to do. I want a way to make a graceful audio player in Javascript that supports transitioning from one audio file to another. The way I was going to implement this is to incrementally reduce the volume on one channel while incrementally increasing the volume on the other channel so I'd get a kind of fade effect. Is there a simpler solution to this using only Javascript? I guess another solution would be to reduce the volume to a certain point, start the new audio file on the same channel, then increase the volume again. This circumvents the need for fading, but I would like to fade if at all possible.

Is this possible? I know the HTML5 spec isn't finished yet, but is there some kind of workaround that you know of? Do any of you have ideas for another approach?

From what I can tell from this post about playing audio in the Android browser, this isn't supported yet, but do any of you know if it will support multiple channel audio once the audio tag is supported? Does opera mini support this?

Community
  • 1
  • 1
beatgammit
  • 19,817
  • 19
  • 86
  • 129
  • It's been a few days and nobody has commented. The page that I referenced plays multi-channel audio on most HTML5 compatible browsers (Opera, Firefox 3.6, Firefox 4 [kind of, a little buggy], Safari, and Chrome). It doesn't work in IE9 (or at least the version that I have), but that doesn't surprise me. – beatgammit Dec 18 '10 at 22:16
  • My friend told me that in the next release of Android this should be fixed. I looked around, and according to a few forums, the Audio tag kind of works in the new Android release (gingerbread). Does anyone know if it supports multiple channel audio? – beatgammit Dec 20 '10 at 20:06
  • Android 2.4 comes out this month. I'll check to see if this works when it comes out. – beatgammit Apr 03 '11 at 19:18

3 Answers3

3

This is an old question I know :).

iOS Safari does not support multiple audio objects playing at the same time. Also, it is not possible for having a fade-in/out effect for iOS, as the only way to change the volume setting is from the hardware itself. Apple decided to give this ability only to the device user. Volume setting is not writable by javascript. It is not even readable (always returns 1).

You can check out the Safari documentation for iOS for more info.

For Android, to be honest I have no idea.

emrahgunduz
  • 1,404
  • 1
  • 13
  • 26
  • +1 Useful information! Does this mean that there is only a global volume? (no per app volume) – beatgammit Dec 17 '11 at 02:59
  • If you are developing a web based app yes, there is only one global volume and one audio channel. For Objective-C based native apps, it is not so different than any other OS. AVAudioPlayer can be used for multiple channels, and it also has a volume setting. Yet it still depends on the global audio. If user lowers or mutes the audio, there is nothing you can do to change it. – emrahgunduz Dec 17 '11 at 11:19
0

I know this is a total hack but try this trick I came up with...

Go to the page below and type on the home row keys to play a blues riff (type multiple keys at the same time etc.)

http://davealger.com/jthump/

The way this works is to create invisible <iframe> components that play a sound before destroying the frame.

I know it is a total hack and I look forward to better HTML 5 multi-channel audio support in the future.

DaveAlger
  • 2,376
  • 25
  • 24
0

There's no direct way that I know of to have multiple channels on an audio tag, but check out this blog post on using multiple audio tags to simulate multiple channels. http://www.storiesinflight.com/html5/audio.html

hobberwickey
  • 6,118
  • 4
  • 28
  • 29
  • That's actually the same link I posted, but I guess that could mean that it's the only valuable data out there... – beatgammit Dec 17 '11 at 03:01