Sign in to follow this  

[web] Playing a sound?

This topic is 3815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Mark

Share this post


Link to post
Share on other sites
The Flash media player thing I linked apparently has a javascript API. Simply loading a SWF with javascript will likely break my pre-load requirement.

Unless I use such a media player, I'd still need an authoring tool.

Edit:

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?

[Edited by - Andrew Russell on July 9, 2007 6:46:19 AM]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

This topic is 3815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this