Moderators: Derry, Goldie, Harpo
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Working Mechanic
Picture of jim476
Posted
Is there a way to program a trigger, such as a mouse click, to generate a random effect?

For example, if a visitor's cursor hovers over a button, can I have it play one randomly-selected audio file the first time this happens, and a different randomly-selected on the next time around?

We're creating a website that we want to be very interactive.

Thanx inadvance.
 
Posts: 18 | Location: New Mexico | Registered: February 02, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
This would be relatively easy to do with javascript, but not advisable. Let's not get into the issue of whether it is wise to force audio on your visitor without his/her approval.

In order to produce smooth audio transitions via a mouse click, you would need to pre-load your audio files on your page. Depending upon the number and size of the audio files, this could greatly increase your page loading time, possibly losing you visitors. The other problem is that embedding audio files on your page would automatically trigger a player to be loaded in the browser page, even if you had player controls set to not auto-play and not be visible.

If you are dead set to do this, I recommend that you use PHP (or ASP) and AJAX techniques. AJAX would let you inject the audio file in response to a mouse click without initially loading the file (and player) on your page. Of course, you would still have a problem with the delay of loading the audio file if it is of any significant size.

Another way which could also reduce the loading delay is to use a flash player capable of handling streaming mp3 files (assuming your audio is in mp3 format to save size). With a flash player, you could use swfobject.js and leverage the script's ability to be dynamically created and destroyed (via a mouse click) thus giving the appearance of audio-on-demand.
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Picture of jim476
Posted Hide Post
Thanx, as usual, Larry. It appears I'm going to have to get serious about learning more about Flash. And for someone like me, that's a major challenge.

FYI, the intent of our new website is to provide entertainment for the visitor who WANTS the interaction. It will be linked from YouTube and other video sites. Our "product," if you wish to call it that, is audiovisual entertainment.

BTW, Larry, our newest website (which won't be open for business for a couple months) has benefitted tremendously from your help. For once, the medium is prepared before the content, rather than the other way around.

Thanx again.
 
Posts: 18 | Location: New Mexico | Registered: February 02, 2009Reply With QuoteEdit or Delete MessageReport This Post
Guru 'Geezer' Mechanic
Picture of larryd
Posted Hide Post
Small, free flash players for audio can be found on the web, so you do not really need to worry about learning flash.

One site that will be of interest is http://code.google.com/p/swfobject and the links found there to examples about using it dynamically. The YouTube API page also has examples of using this script which will be of interest. If you are going to use YouTube, then you may as well use their player, or use the API to personalize the player.
 
Posts: 5097 | Registered: December 03, 2006Reply With QuoteEdit or Delete MessageReport This Post
Honorary Mechanic
Posted Hide Post
jim476,Larry

If these are lets say 10 short (1-2 sec) "bleeps" and "piewpiew" sounds
then that would not take more then a few secs to preload
a 60 kb/s bitrate in Mp3 format will do fine for sounds like that.

If you preload them as last (upper z-layer)
it will not visibly delay the build-up of the page.
and take place while the visitor is still looking around to see
what he can do at your page...i'd say its worth to try.

All you would need to do is prepare your short sounds,
upload them as sound01,sound02...etc
and have a javascript that plays them on mouseover/click some object.

If that works ok enough then you could change the script to make it select the sounds at random.



A Google search for "sound mouseover script"

http://www.google.nl/search?hl...en&meta=&aq=null&oq=


same for "sound mouseclick script"

http://www.google.nl/search?hl...pt&btnG=Zoeken&meta=


same for "random sound mouseclick script" (slightly more difficult)

http://www.google.nl/search?hl...pt&btnG=Zoeken&meta=



Radio
 
Posts: 1053 | Registered: February 27, 2007Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Picture of jim476
Posted Hide Post
I know, I know, I'm a techno-compoop. That's why I need programs like SS to do the thinking for me. Anyway ...

I'm still looking for a way to select sounds from a list randomly, to be played on a mouseover situation. I tried googling and looking at the javascript examples, but that's not a language I understand. (I have a hard enough time with English.)

I just wish there was a way to select "SpecialFX>Mouse Effects" for an object, and tell it in English that I want it to play a sound, randomly, from a predetermined list of sounds.

I'll keep looking for the magic bullet.

And thanx to Larry and Radio for tolerating my ignorance.
 
Posts: 18 | Location: New Mexico | Registered: February 02, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary 'Aussie' Mechanic
Picture of postyr
Posted Hide Post
Hi Jim,

There have been no more prompts from you since, so I thought I would put in my two bob’s worth for you.

The random sound option is a little harder to implement than a simple FX effect. Site Spinner would not build in this option simply because there is not enough call for it. It requires a list (array) of sound files, a method of choosing the random sound, and a way of playing the file. All well outside the purpose of Special FX.

No matter which way you go, you will have to get your hands dirty and use some code.

Javascript is probably the best choice, and with the tools available, you don’t really have to understand it. You only need to read the instructions and change the code where directed.

You realistically have two choices. The choice depends on the size of your sound files. If your sound files are large, you have no option than to use something like the example available here

The only problem with that option is that the sound opens in a new window, or at least opens the user’s default player for the particular type of file.

If your sound files are reasonably small, I have developed my own version, which plays the sound without opening any other window or program.. The only problem with that is, as Larry stated in an earlier post, all of the sounds are “embedded” into the page, so will increase page load time.

My test is done with a mouse over. The link can be changed to mouse click or whatever.

Try it out here

If you cannot work out what has been done from the source code, please feel free to contact me. My email is in my profile.

This message has been edited. Last edited by: postyr,
 
Posts: 1153 | Location: Australia | Registered: April 17, 2007Reply With QuoteEdit or Delete MessageReport This Post
Working Mechanic
Picture of jim476
Posted Hide Post
Thanx postyr --

Your second method is the one that would work best for our purposes. (I'm constantly reminding my associates that everything on the 'net has to be brief; today's audience requires instant gratification, no delays accepted.)

Anyway, I went to your page and lifted the code. I'm now in the process of trying to decipher it and converting it for my use. BTW, your code is for a mouse-over, which is exactly what I'm seeking.

Thanx again.
 
Posts: 18 | Location: New Mexico | Registered: February 02, 2009Reply With QuoteEdit or Delete MessageReport This Post
Honorary 'Aussie' Mechanic
Picture of postyr
Posted Hide Post
If it is of any help, you may find the actual project file easier to understand.

You can download the IMS file here
 
Posts: 1153 | Location: Australia | Registered: April 17, 2007Reply With QuoteEdit or Delete MessageReport This Post
  Powered by Eve Community  
 


™ & © 1998 - 2008, Virtual Mechanics Inc. All rights reserved.