Partager via


IWMSPlayers Object (C#)

The IWMSPlayers object contains a collection of players connected to the server. Each player is associated with an IWMSPlayerIWMSPlayer Object (C#). You can use the IWMSPlayer object to retrieve properties for a specific player.

The IWMSPlayers object exposes the following properties and methods.

Property

Description

Count

Retrieves the number of IWMSPlayer objects that are contained in the IWMSPlayers collection.

length

Retrieves the number of IWMSPlayer objects that are contained in the IWMSPlayers collection. This method is provided for JScript compatibility.

Method

Description

Refresh

Updates the list of IWMSPlayer objects in the IWMSPlayers collection to reflect the connected players.

Remove

Disconnects a specific player from the server and removes it from the IWMSPlayers collection.

RemoveAll

Disconnects all players from the server and removes them from the IWMSPlayers collection.

In C#, there are two ways to access objects in a collection:

  • Access individual objects directly by using a string (where applicable).

  • Iterate through the objects by using an index.

You must use array notation when retrieving objects from a collection, except when using the get_Item method.

Example

The following example illustrates how to retrieve an IWMSPlayers object.

using Microsoft.WindowsMediaServices.Interop;
using System.Runtime.InteropServices;

// Declare variables.
WMSServer          Server;
IWMSPlayers        Players;

try {
    // Create a new WMSServer object.
    Server = new WMSServerClass();

    // Retrieve the IWMSPlayers object.
    Players = Server.Players;
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception e) {
    // TODO: Handle exceptions.
}