Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Button

Status
Not open for further replies.

tmryan

Programmer
Dec 22, 2000
73
US
New to HTML so forgive the simple question.
How do I make a button play a Window's Media file?
I have an input tag like this:
<td> <input type=Submit value=Play></td>
How do I make it launch as wav or mp3 file.

Thanks
tmryan
 
First of all, I think this thread should be in the Voice/Video transmission forum. But I'll go ahead and answer it and maybe we can have it moved.

You need to embed your player into the page using the <object> tag for IE and the <embed> tag for NS. You can encapsulate the <embed> in the <object> so that IE only sees the <object> and NS only sees the <embed>.

eg:
[tt]
<OBJECT
ID=&quot;Video&quot;
WIDTH=&quot;320&quot;
HEIGHT=&quot;240&quot;
CODEBASE=&quot;http:// activex.microsoft.com/ activex/ controls/ mplayer/ en/ nsmp2inf.cab#Version=5,1,52,0701&quot;
CLASSID=&quot;CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95&quot;
STANDBY=&quot;Loading Windows Media Player components...&quot;
TYPE=&quot;application/x-oleobject&quot;>

<PARAM NAME=&quot;FileName&quot; VALUE=&quot;&quot;>
<PARAM NAME=&quot;ShowControls&quot; VALUE=&quot;0&quot;>
<PARAM NAME=&quot;ShowStatusBar&quot; VALUE=&quot;0&quot;>
<PARAM NAME=&quot;ShowDisplay&quot; VALUE=&quot;0&quot;>
<PARAM NAME=&quot;AnimationAtStart&quot; VALUE=&quot;1&quot;>
<PARAM NAME=&quot;TransparentAtStart&quot; VALUE=&quot;0&quot;>
<PARAM NAME=&quot;AutoStart&quot; VALUE=&quot;1&quot;>
<PARAM NAME=&quot;AllowChangeDisplaySize&quot; VALUE=&quot;1&quot;>

<EMBED
TYPE=&quot;application/x-mplayer2&quot;
PLUGINSPAGE=&quot;http:// Windows/ Downloads/ Contents/ Products/ MediaPlayer/&quot;
SRC=&quot;&quot;
NAME=&quot;Video&quot;
WIDTH=&quot;320&quot;
HEIGHT=&quot;240&quot;
ShowControls=&quot;0&quot;
ShowStatusBar=&quot;0&quot;
ShowDisplay=&quot;0&quot;
AnimationAtStart=&quot;1&quot;
TransparentAtStart=&quot;0&quot;
AutoStart=&quot;1&quot;
AllowChangeDisplaySize=&quot;1&quot;>
</EMBED>
</OBJECT>
[/tt]
Ignore the spaces after the slashes in the URLs... they are only there so it would line break and not scroll all the way across the page.

Now, in order to access the plugin from JavaScript, it can be referenced as document.Video or, what I like to do is to name a simple variable:
[tt]
var Player = document.Video;
[/tt]
To assign a file, you should do one of two things. One, you could set the FileName and SRC attributes in the tags. Two, you could set it via JavaScript:
[tt]
if (IE) {Player.FileName = your_file;}
else {Player.SetFileName(your_file);}
[/tt]
This way you can set it dynamically by choosing amongst several files, for instance. your_file can be any media type that WMP can play (mp3, wav, asf, wmf, etc).

In order to play the file, you should use:
[tt]
Player.Play();
[/tt]
There are many other functions you can use, such as stop, fast forward, pause, rewind, etc. There are also other attributes you can access such as the position, packets received, reception quality, etc. Download the WMP SDK from for more info on that.
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top