Tuesday, December 11th, 2007

GWT Voices: Cross browser sound API

Category: GWT, Library, Sound

We featured SoundManager 2 awhile back, and we just ran across GWT Voices, an open source GWT module that abstracts away sound management so you can just do this:

  1. package com.mycompany.client;
  3. import com.google.gwt.core.client.EntryPoint;
  5. import com.allen_sauer.gwt.voices.client.Sound;
  6. import com.allen_sauer.gwt.voices.client.SoundController;
  8. public class SimpleApplication implements EntryPoint {
  9.   public void onModuleLoad() {
  10.     SoundController soundController = new SoundController();
  11.     Sound sound = soundController.createSound(Sound.MIME_TYPE_AUDIO_MPEG,
  12.         "url/to/your/sound/file.mp3");
  14.     sound.play();
  15.   }
  16. }

… and your file will be played across browsers. Voices supports native formats, and drops to Flash for others.

GWT Voices

Posted by Dion Almaer at 7:05 am

3.6 rating from 29 votes


Comments feed TrackBack URI

I’ve been writing a series of Javascript audio tutorials and comments on my blog lately. There a are a few ways to go about it, but my latest foray has been pure Quicktime because it allows you to get a bunch of sweet callbacks to indicate loading and playback position, read ID3 tags, and even adjust the playback pitch. I’ve also released an open-source bookmarklet that installs a music player on any page that links to mp3s.

Comment by jchris — December 11, 2007

Yes the callbacks are nice but it can also be done in Flash/ActionScript. Also, not everyone has quicktime installed :P

I think the percertage of quicktime v. flash users you’d see typically:

Comment by Olmo Maldonado — December 11, 2007

Olmo, you’re right about flash uptake. Sadly flash is too paranoid to allow loading callbacks in the bookmarklet/userscript context. Most music listeners will have QuickTime because it’s included with iTunes. Hopefully HTML 5 will make all this a moot point.

Comment by jchris — December 12, 2007

Leave a comment

You must be logged in to post a comment.