Orionsbelter Posted May 8, 2008 Share Posted May 8, 2008 hi does anyone know how to play a sound in the background of a page. so say like i click on someone thing play a sound. please help. thanks Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 8, 2008 Share Posted May 8, 2008 there are a few ways to do it: 1. invisible flash (1x1 doc) 2. <embed src="yourmusicfile.mid" autostart="true" loop="true" width="2" height="0"> </embed> 3. <bgsound src="yourmusicfile.mid" loop="infinite"> Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted May 8, 2008 Author Share Posted May 8, 2008 and can i echo this? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 8, 2008 Share Posted May 8, 2008 yes Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted May 8, 2008 Author Share Posted May 8, 2008 cheers mate Quote Link to comment Share on other sites More sharing options...
947740 Posted May 8, 2008 Share Posted May 8, 2008 The valid way is to use CSS. I believe the <embed> tags result in an error when validated. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 8, 2008 Share Posted May 8, 2008 CSS can not play sound, it can only be done using "HTML" or "HTML and flash/java" or some other plug-in. Quote Link to comment Share on other sites More sharing options...
947740 Posted May 9, 2008 Share Posted May 9, 2008 Got it mixed up with the background-image. Quote Link to comment Share on other sites More sharing options...
nafetski Posted May 9, 2008 Share Posted May 9, 2008 Please for the love of all that is holy don't make websites that auto play music. Especially midi. Or if it DOES auto play music, give me a big huge button to smash that makes it stop fast. Quote Link to comment Share on other sites More sharing options...
947740 Posted May 9, 2008 Share Posted May 9, 2008 All you have to do is press Esc. Quote Link to comment Share on other sites More sharing options...
nafetski Posted May 9, 2008 Share Posted May 9, 2008 Not for flash, at least not on a mac. Quote Link to comment Share on other sites More sharing options...
947740 Posted May 9, 2008 Share Posted May 9, 2008 True, unless you enable the key. I think it is rather pointless to use flash just for a background sound, however. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 9, 2008 Share Posted May 9, 2008 You also must click on the flash to enable key presses, mouse clicks, etc. Quote Link to comment Share on other sites More sharing options...
947740 Posted May 9, 2008 Share Posted May 9, 2008 That is very true. Another reason I do not like flash. Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted May 9, 2008 Author Share Posted May 9, 2008 how easy is flash to learn and use? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted May 9, 2008 Share Posted May 9, 2008 You flash actionscript could look like this: // create a new Sound object var my_sound:Sound = new Sound(); // if the sound loads, play it; if not, trace failure loading my_sound.onLoad = function(success:Boolean) { if (success) { my_sound.start(); status_txt.text = "Sound loaded"; } else { status_txt.text = "Sound failed"; } }; // load the sound my_sound.loadSound("http://mysite.com/audio/song.mp3", true); Quote Link to comment Share on other sites More sharing options...
Orionsbelter Posted May 9, 2008 Author Share Posted May 9, 2008 i thanks but i used the other one and it worked:D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.