By combining the Windows Media Player control with the TitleView control, you can create an application that allows the user to select a title from the title server and watch it with the player. This simple sample uses HTML and VBScript to demonstrate one solution for playing the current selection in the TitleView control with the Windows Media Player control.
Connecting to the Title Server
The HTML code below starts the page with the default HTML tags, and then adds a text box for the server name, and a button to initiate the set server method.
<HTML>
<HEAD> <TITLE>Simple Title View and Media Player Example</TITLE> </HEAD>
<BODY>
<CENTER>Title Server:
<INPUT TYPE="TEXT" NAME="SrvName" SIZE="25">
<INPUT TYPE="BUTTON" NAME="SetSrv" VALUE="Set Server">
<BR><BR>
Add the TitleView and Windows MediaPlayer Controls
Use <OBJECT> tags to embed the TitleView and Windows Media Player controls in the page. Add a <PARAM> tag to indicate that Windows Media Player must not begin playing the title when the file name is set.
<OBJECT ID="TitleView1" WIDTH=155 HEIGHT=240 CLASSID="CLSID:1E1BAAB1-3614-11D1-A5FE-00AA00BF93E3">
</OBJECT>
<OBJECT ID="MediaPlayer1" WIDTH=360 HEIGHT=240
CLASSID="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95">
<PARAM NAME="AutoStart" VALUE="FALSE">
</OBJECT>
Add a Simple UI for Windows Media Player
Add the play and stop buttons to manipulate the Windows Media Player control.
<BR><BR>
<INPUT TYPE="BUTTON" NAME="PlayBtn" VALUE=" > ">
<INPUT TYPE="BUTTON" NAME="StopBtn" VALUE=" [] ">
<BR>
</CENTER>
</BODY>
Add the Subroutines to Handle Click Events
Add four subroutines: three to process click events for the buttons previously added to the page, and one to respond to the OnSelectionChanged event that is triggered when a title is selected from the TitleView control.
<SCRIPT LANGUAGE="VBScript">
<!--
' Connect to the specified title server
Sub SetSrv_OnClick
TitleView1.SetServer (SrvName.VALUE)
End Sub
' Set the file name based on title selected in TitleView
Sub TitleView1_OnSelectionChanged(Selection)
If selection <> 0 Then
strNewTitle = TitleView1.CurrentSelectionName
MediaPlayer1.FileName = "nsm://" & SrvName.VALUE & "/" & strNewTitle
End If
End Sub
' Play button click event,
' make sure a title has been selected from TitleView.
Sub PlayBtn_OnClick
If MediaPlayer1.FileName = "" Then
MsgBox ("Select a Title to Play")
Else
MediaPlayer1.Play
End If
End Sub
'Stop button click event
Sub StopBtn_OnClick
MediaPlayer1.Stop
End Sub
-->
</SCRIPT>
</HTML>
Putting it All Together
The preceding HTML and VBScript code fragments can be pasted together to create a working Web page. Open the page in your browser, and type in the name of a title server on your intranet. After you connect to the server, you can view the available titles in the TitleView control.
[Previous][Next]