کد:
http://articles.techrepublic.com.com/5100-10878_11-1056946.html
Takeaway: Windows Media Services gives you the power to stream media across your network. Scott Lowe shows you how to use it to create and manage unicast data streams.

Windows 2000 Media Services allow a Windows server to stream audio and video to users over a network or the Internet at various rates of speed. The Daily Drill Down “Prepare your network to support Windows Media Services” explained how to prepare your network for Windows Media Services. But to actually put Windows Media Services to work, you must use the Windows Media Administrator. Here are some examples of how to set up and play media streams for clients and an example of the client monitoring options. I will also introduce some of the basic terms and concepts behind media services.

Using the Windows Media Administrator
When you administer Windows Media Services, the primary tool you’ll use is the Windows Media Administrator. To start it, click Start | Programs | Administrative Tools | Windows Media. When you do, you’ll see the Windows Media Administrator appear, as shown in Figure A.

Figure A

This main screen in Windows Media Services (WMS) is used for configuration tasks and to provide help information.


Rather than go through each section screen by screen, I’ll assume that:

  • · You are working with a nonproduction Windows 2000 server that you can play with a little before deploying to your main network.
  • · You are using a workstation that has Windows Media Player installed.


I won't be supplying too many screen shots, but I will explain in detail how to set up an on-demand system that will play a particular file from the server when you browse to it over your network.

Streaming a sample file
Let’s begin by streaming one of the sample files from the Windows Media Server to your workstation using your browser. If you followed a default installation for the Media Services server, your root directory for Windows Media files is C:\ASFRoot. All ASF files are stored here. If you look in this directory, there are five sample files, but for this example, you’ll work with the one named Welcome2.asf.

First, verify that your On-Demand Unicast Publishing Point folder—a list of locations where you are able to store .asf files and have them streamed—is set properly. To check this, run the Media Services Administrator and click Unicast Publishing Point in the left pane. In the right-hand pane, you should see an alias of <Home> pointing at C:\ASFRoot.

From your client workstation, start Media Player and choose File | Open URL. In the Open field, type mms://servername/welcome2.asf, where you replace servername with the DNS name of your server or its TCP/IP address. You should then see (and hear) an introduction to Windows Media services as it is streamed over your network.

What you've just accomplished is this: you requested a specific .asf media file from the media server. The media server in turn took a look at the Home unicast publishing point (since we did not specify another place to look), found that the Welcome2.asf file was available, and streamed it to the client.

If you have other locations where you would like to put .asf media files, you can add them by using the Unicast Publishing Point section of the Windows Media administration system, which I’ll discuss in just a bit. If you have a limited amount of bandwidth or would like to limit the number of people using a particular publishing point on your server, you can easily do so by selecting the publishing point and clicking the On-Demand button. Then, select Properties to display the screen shown in Figure B. As you can see from the figure, my Home publishing point is C:\ASFRoot, and I do not limit the clients or the bandwidth.

Figure B


You can control the number of users who can access the stream and the amount of bandwidth consumed.


Streaming media from a Web page
In practice, you are probably interested in embedding your media file into a Web page for a user to watch. Make sure Internet Information Services (IIS) is installed on your test server and verify the location of the root folder for the Web server. In a default installation, this is C:\Inetpub\wwwroot.

Let's create two files based on a specific ASF file that we provide. Once again, use the sample file named Welcome2.asf on our Media Server.

First, start the Windows Media Administrator utility and choose Unicast Publishing Points from the menu. In the right pane, next to the On-Demand button, make sure that the Use Wizard To Create On-Demand Publishing Point check box is selected. Click On-Demand | New to start the Configure And Publish Unicast On-Demand Streams Wizard. The first screen you’ll see is the standard splash screen, so click Next to display the Select A Publishing Point screen shown in Figure C.

Figure C

You can select publishing points using a wizard.


Although you can use the wizard to create new publishing points, you won't be actually creating a new publishing point. You'll use this wizard to generate some HTML code to generate a player window in a Web browser for your .asf files instead of using Media Player directly. At the same time, you'll also generate HTML that launches Media Player from a Web page rather than embedding it.

Make sure you have the <Home> publishing point selected and that you have selected the Select Existing Publishing Point radio button.

The next screen asks you for the location of the ASF file that you want to work with. Click Browse to see a directory listing of C:\ASFRoot and choose the file Welcome2.asf from the list. The next screen is the Select Publishing Method screen shown in Figure D.

Figure D

You can use the publishing point wizard to help create HTML pages.


On this screen, make sure you choose MMS as the protocol and tell the wizard to create both of the .htm file options. One of the files will start Media Player in an embedded window, while the other will launch the Media Player application. The next screen provides you with a summary of the choices you made with the wizard. Clicking Finish doesn’t quite finish the process, though. Instead, you'll see the Save .ASX File dialog box appear. Here, you tell the wizard where you want to store the ASX file associated with the ASF file. An ASX file contains a pointer to the ASF file. For this example, tell the wizard to store this file in C:\inetpub\wwwroot or in the root of your IIS Web server if it is not the default. There will also be two more files, Welcome2_href_tag.htm and Welcome2_object_tag.htm, that will need to be stored in the same location. You’ll see Save As dialog boxes appear for each of these files as well.

On the next screen, don’t bother with any of the testing options, because you’ll test the files from a client. Just click Close to return to the administration program.

Then, from your client, browse to the following address:
http://server/ welcome2_href_tag.htm

Naturally, you’ll replace server with the DNS name or TCP/IP address of your Web server. Browsing to this address will bring up a very simple Web page with one link that says HREF To Welcome2.asf.

When you click on the link, a separate Windows Media Player window will open and play the video for you. In this example, the HTML in the page references the .asx file that you created with the wizard. The .asx file in turn references the .asf file by using the MMS protocol. As a result, Windows Media Player is launched in its own window.

If you want to see what it looks like to embed Media Player within your Web page, go to your client and type:
http://server/ welcome2_object_tag.htm

This time, you’ll see the Web page appear, but Media Player will display within the Web page. After the page loads, Media Player will instantly run the file.

A look at the HTML code
If you like to hardcode and create your own Web pages, you may be interested to know what the HTML code for this looks like. Here is the HTML file generated from the page we just looked at.

When the following HREF is selected, a browser downloads the .asx file and tries to run the file. This launches the Microsoft Windows Media Player, which opens the file and plays the URL. Media Player assumes that this .htm file and the .asx file are located in the same directory.

Here is the HTML for the embedded option. As you can see, it is much more substantial, as it contains all of the parameters for the Media Player to function properly.

When I need an On-Demand file for a Web page, I like to use the wizard to create it and then take the parts of the HTML that I need and tweak them to my liking, instead of manually typing all this in.

Client monitoring
While your clip is playing on your client machine, let’s take a quick peek at the Windows Media Server console. Here, you can view how the streams are leaving your server. Click on Publishing Point Clients and select Enable Client Monitoring. When a client starts accessing streams from your server, you’ll see the screen shown in Figure E.

Figure E

You can monitor streams as they flow from your server.


If you don’t initially see any connections listed, click the Refresh button. At the bottom of the Windows Media Administrator screen, you’ll notice the Auto-Refresh check box. Select this box to force Windows Media Administrator to automatically refresh its display. You can tell it how often to refresh in the Seconds field. Don’t set this number too low, or you’ll cause your server to take extra time refreshing screens when it could be serving streams.

In this example, you can see that there is a client at IP address 192.168.59.1 on port 1135 streaming the file C:\Test\walk.asf . You'll also notice the Terminate Selection button at the top of the window. This is useful if your server is experiencing performance problems and you need to lighten the load a little. If so, clicking the button kills the stream.

Conclusion
When you use Windows Media Services to provide access to multimedia streams for your users, those users will gain a new and powerful tool for distributing information. However, to make the streams work properly, it's important to understand how to work with the unicast streams that will be flowing from your server. Then, you can turn streaming media loose on your users




موضوعات مشابه: