playing short sound files without controls on the page

L

laredotornado

Hi,

Is there a cross-browser way to play short (< 25K) sound files without
spawning new windows or embedding any visual controls on the page? I
would like to click a button and hear my short sound.

Thanks for your help, - Dave

ps - Searching Google turned up stuff for Netsacpe and IE 3, but I was
hoping more for IE 7 and Firefox.
 
G

getburl

Hi,

Is there a cross-browser way to play short (< 25K) sound files without
spawning new windows or embedding any visual controls on the page? I
would like to click a button and hear my short sound.

Thanks for your help, - Dave

ps - Searching Google turned up stuff for Netsacpe and IE 3, but I was
hoping more for IE 7 and Firefox.

Hey Dave,

The easiest way is to attach an 'embed' element and then change the
src attribute. This willl load the file at that time and play it when
it is loaded.

I also wrote a small sound class for a particular need I had. I posted
it here http://adambragg.blogspot.com/

getburl
 
L

laredotornado

Hey Dave,

The easiest way is to attach an 'embed' element and then change the
src attribute. This willl load the file at that time and play it when
it is loaded.

I also wrote a small sound class for a particular need I had. I posted
it herehttp://adambragg.blogspot.com/

getburl

Thanks for posting this. This is a very cleanly written class. I do
have one question. is calling the "draw" function the equivalent of
calling play? So, if someone clicked on a button labeled "Play",
would the right JS be

var s = new Sound();
s.initialize('/path/to/my/sound', null, 'arbitraryId');
s.draw();

?

Thanks again, - Dave
 
G

getburl

Thanks for posting this. This is a very cleanly written class. I do
have one question. is calling the "draw" function the equivalent of
calling play? So, if someone clicked on a button labeled "Play",
would the right JS be

var s = new Sound();
s.initialize('/path/to/my/sound', null, 'arbitraryId');
s.draw();

?

Thanks again, - Dave- Hide quoted text -

- Show quoted text -

Sort of. I called it draw because that is more literal. Render would
be even more literal because the DOM element is being inserted into
the DOM of the page. So, the element is being drawn or rendered on the
page. Then there is load time until the sound plays. So, you could
rename it to play if that is more intuitive. Very good point. I may
have to change that.
 
G

getburl

Thanks for posting this. This is a very cleanly written class. I do
have one question. is calling the "draw" function the equivalent of
calling play? So, if someone clicked on a button labeled "Play",
would the right JS be

var s = new Sound();
s.initialize('/path/to/my/sound', null, 'arbitraryId');
s.draw();

?

Thanks again, - Dave- Hide quoted text -

- Show quoted text -

I did not read your code quite as well as I should have. The correct
instantiation would be:

var s = new Sound('/path/to/my/sound', null, 'arbitraryId'); //
initialization is implicit when the object is instantiated
s.draw();
 
L

laredotornado

I did not read your code quite as well as I should have. The correct
instantiation would be:

var s = new Sound('/path/to/my/sound', null, 'arbitraryId'); //
initialization is implicit when the object is instantiated
s.draw();

Thanks. Just one more thing. When I load this script in the latest
version of Firefox on the PC, I'm getting a "Class is not defined"
error, supposedly referring to the line

var Sound = Class.create();

Was there something else I was supposed to include in addition to the
lines posted on your blog?

- Dave
 
G

getburl

Thanks. Just one more thing. When I load this script in the latest
version of Firefox on the PC, I'm getting a "Class is not defined"
error, supposedly referring to the line

var Sound = Class.create();

Was there something else I was supposed to include in addition to the
lines posted on your blog?

- Dave- Hide quoted text -

- Show quoted text -

Hey Dave,

Yes, the class is based on the Prototype Framework found at http://
prototypejs.org/
The Sound class I wrote could be ported to a standalone class. I wrote
it based on Prototype out of my own specific need.

getburl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top