Closed Thread Icon

Topic awaiting preservation: DHTML Sound API (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=23667" title="Pages that link to Topic awaiting preservation: DHTML Sound API (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: DHTML Sound API <span class="small">(Page 1 of 1)</span>\

 
Scott
Bipolar (III) Inmate

From: schillmania.com
Insane since: Jul 2002

posted posted 10-16-2004 00:19

http://www.schillmania.com/projects/soundmanager

Some of you guys know I've been playing around with JS -> Flash communication stuff for a while, for various things (usually embedding sound to be controlled via Javascript, or socket communications etc.) .. I finally got around to writing an object-based wrapper class, object, whatever you care to call it, that will handle this nicely.

How it works:

A single SWF (not Single White Female, I'm talking Flash here. Yes, that was a bad joke,) is embedded and given an ID for reference. This movie loads an XML file and creates a movie clip for each <sound /> entry.

eg. <sound id="someNoise" href="beep.mp3" />

(This is nice since you don't have to mess with Flash to add or remove sounds, etc. It's all based on the XML file.)

So movie clips are created with the ID as specified in XML. Each one contains frames with labels on them for basic functionality (like "stop" and "play" etc.)

Back in JS land, a call can be made to the API ie.
soundManager.play('someNoise');

This grabs the Flash movie and calls the TCallLabel() methods etc. This method targets a specific movie clip and associated frame (by label.) eg. flashMovieID.TCallLabel('someNoise','play');

I wrote in some other functionality for setting properties and calling methods on sound objects from within flash, but called (originated) from Javascript - so if you need a certain Sound object method called, it's trivial to add in.

I made a method for this: callMethod(soundID,methodName,methodParam);

So eg. adding a "setVolume" function is easy:

this.setVolume = function(soundID,volume,movieName) {
self.callMethod(soundID,'setVolume',volume,movieName);
}

Which ends up making two calls - one to set variable X in Flash via TCallLabel(), then a second TCallLabel() to run the "call this function and pass it X".


Known gotchas are as follows:

- Looping with sound objects importing external MP3s etc. isn't seamless.
- ie:mac does not support this - Mozilla/Safari *might*, but my testing so far has shown otherwise unfortunately. Opera is another unknown, likely unsupported.

I also think I improved the prevention of crashing in IE, which would happen from time to time in my earlier DHTML Arkanoid project (ie. too many simultaneous sound calls) which used a different Flash method.

This thing's on my site for anyone to download and play with if interested of course. As I said on my site: Sound for the web may not necessarily be needed everywhere, but I think when used appropriately it can enhance the experience without tarnishing it.

(Edited by Scott on 10-16-2004 00:21)

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

posted posted 10-16-2004 04:15

Great and clever stuff as usual!

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 10-18-2004 19:06

Excellent stuff, I remember looking for someway to do this years ago, the best way I found was switching html pages in a hidden frame.
Is this how sounds are done around about your site ?

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

posted posted 10-18-2004 23:42

^^^
Thanks.

Switching out pages is a unique way of doing it (theoretically, pretty reliable eg. an object/embed or whatever,) but I'd imagine you'd get some funny behavior if you wanted to play a bunch of sound at once. Still neat however.

The code on the project page is adapted from what's on my main site at the moment, but I added more functionality and made it more modular (and easier to swap out sounds etc.)

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 10-24-2004 21:49

I'm really liking this. If and ONLY if it is fully okay with yourself, could I implement it in my new new design (won't be finished for months) ? I'd probably keep it simple with blip here and there and the odd tiny whoosh noise.
Also, would a link in a links page and a mention in the source code suffice as a credit to yourself ?

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

posted posted 10-25-2004 16:50

For sure Hugh, the idea behind this is it's freely available for that! You can grab a copy from the URL in the first post.

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 10-25-2004 18:04

hmm... I'm wondering if this couldn't be expanded to a full library that could do sound, sockets and dynamic content all in one little flash app.



.:[ Never resist a perfect moment ]:.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 10-25-2004 18:09
quote:
Hugh said:

I'd probably keep it simple with blip here and there and the odd tiny whoosh
noise.


Me too! I've strayed away from sound on my designs because it was always so poorly supported in most browsers. But this may just be the thing to make me rethink incorporating it. The occasional click and blip would be most cool I think. Thanks for sharing this, Scott.

: . . DHTML Slice Puzzle : . . .

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-25-2004 19:19

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Scott
Paranoid (IV) Inmate

From: schillmania.com
Insane since: Jul 2002

posted posted 10-25-2004 20:56
quote:
bitdamaged said:

hmm... I'm wondering if this couldn't be expanded to a full library that could do sound, sockets and dynamic content all in one little flash app. .:[ Never resist a perfect moment ]:.



You're thinking the same thing I've been thinking .. I've been messing around with socket stuff via Flash as well, in theory it wouldn't take too much to expand this functionality.

(Edited by Scott on 10-25-2004 20:56)

Hugh
Paranoid (IV) Inmate

From: Dublin, Ireland
Insane since: Jul 2000

posted posted 10-27-2004 13:03
quote:
InI said:
InI's problem: I know Flash, ActionScript, quite well, have fooled
around with both as a programmer. Even played with some flash internal
bytecode.
But I will never embed a single swf in one of my pages, hidden or not.

Why? Because it will crash on some Linux, because it will mess up with
corporate network that use special security settings, because in a way
or another,
it will drag some users off my site... because it is not a standard.



Get cracking on a Java Applet alternative so ! or would that have the same problem. I think its been done with Java but badly and wouldnt have the MP3 ability.

Scott: Just downloaded it, 2kb, very nice ! Now when I redesign my site I'll have to come up with some tiny sounds and get some program to make 'em. WAILING GUITARS, no not really.

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

posted posted 10-27-2004 14:46

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Ray Norrish
Nervous Wreck (II) Inmate

From:
Insane since: Sep 2004

posted posted 10-29-2004 01:18

The tracker module player I use for playing Amiga mods is written in Java. It's also possible to place SFX into the module and play the SFX by param mode. Not ideal, but a Java way of course. No doubt the guy could rework his code to make a nifty SFX player which uses the MOD soundbank for the fx sounds. An added bonus is the ability to apply realtime FX to the original sound.. the same sample or WAV could have multiple playback options, using the tracker FX (offset, repeat, pitch changer and many more.)
The player I use is, as far as I know - exclusive to me and has had added automatic GZip compression - I am not a java programmer, and I am very grateful to the guy who wrote and modified the player for me (it was originally the mhumhu system - or something like that), It plays XM with many FX and I would be happy to discuss with him extending this Java player to be an SFX app.

The player can also operate in the standard SUN JAVA mode (8bit) or take advantage of Direct X in signed mode for 16bit playback. Check out the filesizes and playback quality at my site : http://norrish.force9.co.uk/amiga

Ray Norrish
Nervous Wreck (II) Inmate

From:
Insane since: Sep 2004

posted posted 10-29-2004 01:26
quote:
InI said:

mummuaudio lib at www.komplex.org for instance(and I got instances a plenty, oooold instances dating from years ago).



It's very very good. I shamefully hassled Fredrik for modifications and he made me the great player I use now on my site. I think there's great potential for it and as far as I know, the player he made for me is the best rendition yet.. much better than the player used for the old komplex demos.

« BackwardsOnwards »

Show Forum Drop Down Menu