[thelist] Can't get embedded media to play with JavaScript

John Dowdell jdowdell at adobe.com
Fri Jul 20 11:17:19 CDT 2007

Rick den Haan wrote:
> On an AJAX-heavy application, sometimes sound effects are required. To do
> this, on page load, a couple of WAV files are embedded into the HTML
> document from an external JS file using DOM. I'm using EMBED here because
> this should be cross-platform, and I don't want to force a particular
> player. Who knows what plugin the visitor is using to play back a WAV file,
> it could be WMP, QuickTime, RealPlayer, and who knows what else. So I'll let
> the browser figure it out for itself.

This is possible, but may be difficult. If you present a WAV and intend 
to control it with JavaScript, then two conditions must be met:
(a)  whichever WAV player is set as each audience member's default 
player must be able to accept JavaScript commands;
(b)  whichever browser is set as each audience member's default browser 
must be able to send JavaScript messages to plugins.

Among conformant WAV players and browsers, there can be slightly 
different syntax, as you've already seen. But this doesn't mean that all 
audience configurations will be able to support JavaScript control over 

The standard approach is to handle interactive audio duties through 
Adobe Flash Player 9, which is currently installed into well over 90% of 
the world's browsers. The interactivity and media can both be handled in 
the same environment, and so cuts the development and maintainence costs 
of trying to get each possible browser to accurately communicate with 
each possible audio engine.

If you're committed to an all-JavaScript approach, then one technique is 
to put all the audio in an invisible frame, and handle on/off controls 
by loading appropriate webpages into that hidden frame.


John Dowdell . Adobe Developer Support . San Francisco CA USA
Weblog: http://weblogs.macromedia.com/jd
Aggregator: http://weblogs.macromedia.com/mxna
Technotes: http://www.macromedia.com/support/
Spam killed my private email -- public record is best, thanks.

More information about the thelist mailing list