Navigation
Poll
Would you be an active poster if Ron's Guide had a message board?


Total Votes: 62
Comments: 18 — View
Past pollsPoll idea?
Rate Ron's Guide
Rate our resource at Bigwebmaster.com
Embedded Music
This tutorial will show you how to have music play on your webpages.

To add music to a webpage, all you need to do is use the <embed> tag to have the music be embedded straight into your page. Using the <embed> tag will allow your visitors to control the music directly from your webpage. All you need to do is define the src of your music file. Here's an example:

<embed src="path/to/mymusic.mid" />

Depending on which media player your browser uses, the code above will produce somthing this:

To get it working, all you need to do is replace path/to/mymusic.mid with the URL to your music file. You can also add additional options by using some of the attributes that go along with the <embed> tag.

For example, you can change the height and width of the media player above with the height and width attributes. Just add them to the embed tag like this:

<embed src="path/to/mymusic.mid" width="185" height="45" />

The code above will make it nice and compact, like shown below:

Some other useful attributes are the autostart, loop and hidden attributes.

If autostart is set to false (the default is true) the music will not start playing until the user clicks the play button on the media player control bar.

If loop is set to true (the default is false) the music will start playing again automatically when it reaches the end.

If hidden is set to false (the default is true) the media player will not show in the browser window.

Here's an example of how to use these attributes:

<embed src="mymusic.mid" autostart="true" loop="true"
hidden="true" />

In the example above, I could have just left out the autostart attribute, because the default is already true, but I just wanted to demonstrate how to use these attributes for those who didn't already know.

That's it! Pretty easy huh? I hope this tutorial helped you.

Discuss Tutorial: Embedded Music 22 Comments
Comment by Ron on Jun 21, 2004, 5:45 am
Please post questions or comments about this tutorial below. Smile
Comment by Missy on Jun 21, 2004, 8:06 pm
Can you add your own images to it? Like for the body, okay and such?
Comment by Ron on Jun 22, 2004, 12:31 am
I'm not sure what you are asking Undecided
Comment by DarkJedi613 on Jun 25, 2004, 5:28 pm
A word of warning to you all who want to add background music - a lot of people hate it so make sure they can shut it off if the autostart is on.

When I had it on my site a lot of people complained that it was annoying, etc. So just make sure it is appropriate to use.
Comment by unsc on Nov 26, 2004, 10:14 pm
can you use that for movies too?
Comment by Ron on Nov 27, 2004, 9:14 pm
Yes, you can. Smile
Comment by Michael on Dec 6, 2004, 1:02 pm
how can i put this in an iframe and how put in my music
can some 1 tell me plz
Comment by Michael on Dec 6, 2004, 1:05 pm
ok the music part i found out Grin
Comment by Michael on Dec 6, 2004, 1:24 pm
or even better get it at the bottom of my page it would be my guess align but that is not working can you help me with this one plz
Comment by Michael on Dec 16, 2004, 4:19 pm
Why cant some1 awnser me? Crying

« Previous [ 1 2 3 ] Next »
Post a comment
Sorry, you must be a registered member to post comments.

If you would like to register, you can do so here.
If you already have an account, please login.