Windows Media : Simple Buttons

Description: Goal- Incorporate simple buttons in a Web page that allow you to stop, play, and pause the Windows Media Player in both Microsoft Internet Explorer and Netscape Navigator. This sample describes how to incorporate simple buttons for the Windows Media Player into a Web page. These buttons will work in any browser that supports the Windows Media Player Plug-in and JavaScript.

By adding custom buttons that control the Windows Media, you (as the Web page author) are allowed more control over the look and feel of the page.

The Windows Media Player supports over 20 methods. We'll use the three most common here -- Play(), Pause(), and Stop().

Code to Include

We'll start with our generic cross-browser code embedding code. This code will instantiate the Media Player ActiveX control for browsers which support ActiveX, and the Media Player plug-in for browsers that don't:

<object id="MediaPlayer1" width="160" height="112" classid="clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"> <param name="FileName" value="http://webserver/path/your-file.asx"> <param name="ShowControls" value="False"> <param name="ShowStatusBar" value="True"> <embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="http://webserver/path/your-file.asx" name="MediaPlayer1" width="160" height="112" showstatusbar="true" showcontrols="false"></embed></object> You'll notice that we're using two properties of the Media Player control here, ShowControls and ShowStatusBar. By setting ShowControls to "false," we're hiding the default Media Player Control bar. By setting ShowStatusBar to "true," we're explicitly showing the Media Player Status bar in order to give the user some feedback as to what the Media Player is doing. Next, we'll define a form and some buttons:
In the code above, all of the buttons make calls through JavaScript directly to the Media Player using the Document Object Model(DOM). Browser/Platform Compatibility This code will work with Internet Explorer 4+, and Netscape Navigator 4+ on platforms that support the Windows Media Player plug-in and ActiveX control.

Complete Article

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish