Share via


Adding the Scripting Code

Windows Media Player SDK banner art

Scripting code adds interactivity to your page, enabling you to respond programmatically to events, to call methods, and to change run-time properties. First, you must use a SCRIPT tag to notify the browser which scripting language you intend to use. Include your script commands within HTML comment tags so browsers that do not support scripting do not render your code as text. Put the SCRIPT tag anywhere within the BODY of your HTML file and embed the comment-surrounded code within the opening and closing SCRIPT tags.

The following code calls the Windows Media Player control methods in response to events triggered by clicking the button controls.

<SCRIPT LANGUAGE="VBScript">
<!--
Sub BtnAbout_OnClick
   MediaPlayer1.AboutBox
End Sub

Sub BtnPlay_OnClick
    MediaPlayer1.Play
End Sub

Sub BtnStop_OnClick
    MediaPlayer1.Stop
    MediaPlayer1.CurrentPosition = 0
End Sub
-->
</SCRIPT>

Each subroutine is attached to a specific button that was defined previously. When an event is triggered by a button click, the code makes a call (or series of calls) to the Windows Media Player control, specifying the action to be taken.