Embedding Windows Media Player or Background Sounds into a Website

Also notice, that you do not have to have the full URL if the audio or media files are on your local server.
You can use this
src="musicfolder/audiofile.wma" in place of this src="http://www.address.com/musicfolder/audiofile.wma” This would be used in case the audio file is located on another server or website.

 

This code will auto play music file in the webpage background upon accessing it.

 

<embed src="http://www.address.com/musicfolder/audiofile.wma" autostart="True" loop="false" volume="20" hidden="true"/>

 

 

This code will display the audio or media file on your site.

 

<object id="MediaPlayer" height=46 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">

 

<param name="filename" value="http://www.address.com/musicfolder/audiofile.wma">

<param name="Showcontrols" value="True">

<param name="autoStart" value="True">

 

<embed type="application/x-mplayer2" src="http://www.address.com/musicfolder/audiofile.wma” name="MediaPlayer"></embed>

 

</object>

 

 

 

WMV (Windows Media Video) Inline Embed and Stream Code

 

<object id="MediaPlayer" classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="480" height="360" standby="Loading Windows Media Player components..." type="application/x-oleobject"

codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112">

<param name="FileName" value="http://www.address/filaname.wmv">

<param name="AutoStart" value="true">

<param name="ShowControls" value="true">

<param name="BufferingTime" value="2">

<param name="ShowStatusBar" value="true">

<param name="AutoSize" value="true">

<param name="InvokeURLs" value="false">

<param name="AnimationatStart" value="1">

<param name="TransparentatStart" value="1">

<param name="Loop" value="0">

<embed type="application/x-mplayer2" src="http://www.address.com/audio.wma" name="MediaPlayer" autostart="1" showstatusbar="1" showdisplay="1" showcontrols="1" loop="0" videoborder3d="0" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="480" height="360"></embed>

</object>

 

 

 

This code will play audio file in the background and give you the choice to Stop Music or Play Music.

(Will also work in Wordpress or php, html files.) I am using this code below on my WordPress site and it works great in the header or on a page.

 

<embed src="http://www.address.com/musicfolder/filaname.wma" id="music" hidden="true" autostart="true" name="mySound"></embed>

<a href="javascript:document.embeds['mySound'].stop()">Stop Music</a>

<a href="javascript:document.embeds['mySound'].play()">Play Music</a>

 

 

Gives you the option with the word “Play Music” on your site to play sound in the background. But you cannot shut it off.

 

Background sound example :
<a href="http:youraddress/music/myfile.wma">Play Music</a>

 

 

 

EMBEDDING AUDIO:

Internet explorer supports the BGSOUND and Netscape supports an embed tag for embedding music.

In Internet Explorer, the audio can be played using the <BGSOUND> tag. bgsound tag works only in IE and not in any other browsers. You will have to use the EMBED tag.

Example:

<bgsound src="http://www.address.com/mymusicfile.wav" LOOP="-1" >

The audio can be included using <embed> tag for Netscape like browsers.

Example Code:

<EMBED SRC=" http://www.address.com/mymusicfile.mp3" HIDDEN="true" AUTOSTART="true" LOOP="infinite" Height=145 width=160></EMBED>

This will include background music into your webpage. If you want to display the controls in the browser, you can set the hidden attribute to false. Here in the above example we have used Loop=-1 which will play the file again and again. If you want to play it only once just set the loop to false.

 


ATTRIBUTES FOR USE OF EMBED:

SRC: This attribute gets the audio from the source to the URL. (where you embedded it on your webpage)

WIDTH and HEIGHT: Manages the size of the Player  in the html page.

AUTOSTART: Value can be either TRUE or FALSE.
     TRUE: Plays the sound file as soon as the webpage is loaded.
     FALSE: Plays the sound file after the user clicks a play button.

LOOP: FALSE plays the audio one time TRUE plays it continuously (over and over again).

 


EMBEDDING BACKGROUND SOUND USING META:

Example:

<meta http-equiv="REFRESH" content="0;URL='http://www.address.com/musicfile.wav'" >

When you use a META tag you will get a conformation as to what player or what do you want to do with this file. For example, if you are opening with Windows Media Player then, the browser will take you to the windows Media player to play the audio file.

 


Using an Object Tag:

Besides the non standard EMBED tag, we can also use the <object> tag for embedding medias into our web pages. But, it is not completely effective for cross-browser functions.

You can specify some parameters related to the document with the param tag. IE may needs an SRC parameter to understand the location of the audio file.

Example:
<object data="music.wav" type="audio/x-mplayer2" width="320" height="240">
<param name="src" value="music.wav">
<param name="autoplay" value="false">
<param name="autoStart" value="0">
Hear the music: <a href="musicfolder/music.wav">Play Music</a>
</object>


Type
attribute will specifie the application/media player type you are using.

Use the following type for your specific media player,
Windows Media Player : type="application/x-mplayer2".
Quicktime: type="video/quicktime".
RealPlayer: type="audio/x-pn-realaudio-plugin".