[web] Playing a sound?

Started by
6 comments, last by Luctus 16 years, 9 months ago
Simple question: what's the best way to play a sound on a website? Ideally I'd be able to "call" it from &#106avascript. Also compression and pre-loading are important. One of my ideas was to have a hidden flash media player on the site. One that exposes JS functions to play sound. Is this workable? One problem would be that it could only play one sound at a time. It will most likely be on mouse-over and mouse-down events, so embedding actual Flash would be acceptable - but I don't have an authoring tool - so it only works if there is a suitable, free, easy to use authoring tool out there. What options are there and how do they compare?
Advertisement
Steve just panicked when I linked him this thread. It's ok! It's an "arty" website. Sounds are acceptable.
Using Flash is the most portable and straightforward method. Other options depend on plugins which might not be available or work on a given platform.

I don't have the authoring tool either - in the past I got a colleage to create me a tiny swf that just plays a sound (based on a parameter) as soon as it's loaded.

It's possible to load the swf using &#106avascript (Just create the element(s) necessary using DOM or .innerHTML) and the sound will play.<br><br>Mark
The Flash media player thing I linked apparently has a &#106avascript API. Simply <i>loading</i> a SWF with &#106avascript will likely break my pre-load requirement.<br><br>Unless I use such a media player, I'd still need an authoring tool.<br><br>Edit:<br><br>But an important question: Can &#106avascript calls go into, and sounds come out of, a hidden Flash object? What's the best way to hide it? CSS display: none? Or something more complex/hacky?<br><br><!--EDIT--><span class=editedby><!--/EDIT-->[Edited by - Andrew Russell on July 9, 2007 6:46:19 AM]<!--EDIT--></span><!--/EDIT-->
I hear OpenOffice can export Flash, these days?

How useful is it for this purpose? How useful is it for web content in general?
you can send it to out of screen.
or just hide it.
© Loading... !!!
Please Wait...!
OOo exports only presentations or images, so it's on no use to you. As for display: none; I am not sure it works everywhere. Flash might fight back because it's a plugin and not something native to the browser. Kinda like it fights you when CSS dropdowns disappear below it. I suggest making the visual part of the flash just a 1x1 transparent pixel and put it somewhere out-of-the-way, then control it with &#106avascript.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Quote:Original post by Andrew Russell
It will most likely be on mouse-over and mouse-down events, so embedding actual Flash would be acceptable - but I don't have an authoring tool - so it only works if there is a suitable, free, easy to use authoring tool out there.

What options are there and how do they compare?


Not sure if this is what you want, but there's a (free) product called GOA WinForms which allows compiling C# code to flash movies. A very small subset of the CLR is avaliable, mostly System.Windows.Forms obviously, but also a few methods for loading and playing sound. Here's a link to the documentation since it's a bit tricky to find.
-LuctusIn the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move - Douglas Adams

This topic is closed to new replies.

Advertisement