Welcome to Dream.In.Code
Become an Expert!

Join 149,523 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,455 people online right now. Registration is fast and FREE... Join Now!




Playing an mp3 on a website

 
Reply to this topicStart new topic

Playing an mp3 on a website, in xhtml with css

helen
28 May, 2007 - 12:56 AM
Post #1

New D.I.C Head
*

Joined: 28 May, 2007
Posts: 1


My Contributions
I'm hoping this is quite simple, I've setup a website for a local band to what they've asked for excluding one part. They would like to have an mp3 of them playing in the background when people view the site.

I've googled this and i've not had much luck with the results, what tag/attributes would I need to implement this please?

(Yes, I'm still relatively new to programming!).

Thank you for your help.


User is offlineProfile CardPM
+Quote Post

girasquid
RE: Playing An Mp3 On A Website
28 May, 2007 - 06:26 AM
Post #2

Barbarbar
Group Icon

Joined: 3 Oct, 2006
Posts: 1,294



Thanked: 18 times
Dream Kudos: 725
My Contributions
The best way to do this would be to use a Flash movie that loaded in the .mp3 and played it.
User is offlineProfile CardPM
+Quote Post

matt64
RE: Playing An Mp3 On A Website
28 May, 2007 - 01:57 PM
Post #3

New D.I.C Head
*

Joined: 28 May, 2007
Posts: 1


My Contributions
hey helen

try somthing like this its javascript and will play a bg sound that you point it to

CODE

<script>
<!--
var sound1="first.mid"
var sound2="second.mid"
var sound3="third.mid"
var sound4="fourth.mid"
var sound5="fifth.mid"
var x=Math.round(Math.random()*4)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else x=sound5
if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="infinite">')
else
document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0" width="20" height="20" autostart="true" loop="true">')
//-->
</script>

User is offlineProfile CardPM
+Quote Post

k0b13r
RE: Playing An Mp3 On A Website
28 May, 2007 - 02:41 PM
Post #4

D.I.C Head
Group Icon

Joined: 18 Jul, 2006
Posts: 198



Thanked: 1 times
Dream Kudos: 250
My Contributions
If you're not good with Flash/ActionScript try this example:
CODE

http://www.entheosweb.com/Flash/flash_sound_button.asp

Just import another file and everything is working smile.gif
Have fun biggrin.gif
User is offlineProfile CardPM
+Quote Post

ahmad_511
RE: Playing An Mp3 On A Website
28 May, 2007 - 06:16 PM
Post #5

D.I.C Regular
Group Icon

Joined: 28 Apr, 2007
Posts: 351



Thanked: 8 times
Dream Kudos: 400
My Contributions
Hi.
It's just a trick but it works good on IE
Just rename your song.mp3 to song.au
Then configure the background sound to play this song
CODE

// In the header
<bgsound src="./Almost_A_Whisper.au" loop="1">

you can let javascript to select the current playing song if you want to.
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Playing An Mp3 On A Website
28 May, 2007 - 06:23 PM
Post #6

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,303



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
You can also embed a Windows Media Player into the HTML code and play the song that way. Windows Media Player can play native mp3 files.

How to embed a WMP in HTML.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 08:44PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month