[web] Playing a sound?
Simple question: what's the best way to play a sound on a website?
Ideally I'd be able to "call" it from javascript. 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?
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 javascript (Just create the element(s) necessary using DOM or .innerHTML) and the sound will play.<br><br>Mark
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 javascript (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 javascript API. Simply <i>loading</i> a SWF with javascript 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 javascript 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?
How useful is it for this purpose? How useful is it for web content in general?
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 javascript.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement