Share via


IWMSActiveStreams Object (C#)

banner art

Previous Next

IWMSActiveStreams Object (C#)

The IWMSActiveStreams object contains a collection of IWMSActiveStream objects that provide information about specific audio and video streams in the active media element. The IWMSActiveMedia object provides information about the active element.

The IWMSActiveStreams object exposes the following properties.

Property Description
Count Retrieves the number of IWMSActiveStream objects in the IWMSActiveStreams collection.
length Retrieves the number of IWMSActiveStream objects in the IWMSActiveStreams collection. This method is provided for Microsoft JScript compatibility.

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 Code

The following example illustrates how to retrieve an IWMSActiveStreams object.

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

// Declare variables.
WMSServer          Server;
IWMSActiveMedia    ActiveMedia;
IWMSActiveStreams  ActiveStreams;
IWMSPlayers        Players;
IWMSPlayer         Player;
IWMSPlaylist       Playlist;

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

    // Retrieve an IWMSPlayers object.
    Players = Server.Players;

    // If players are connected, retrieve the first IWMSPlayer object
    // in the IWMSPlayers collection.
    if (Server.Players.Count > 0)
    {
        Player = Server.Players[0];

        // Retrieve the IWMSPlaylist object for the player.
        // NOTE: A valid playlist file is not always returned.
        // This may be the case, for example, if the user requested
        // a specific content file or if a broadcast publishing point
        // is being used.
        Playlist = Player.RequestedPlaylist;

        if (Playlist != null)
        {
            // Retrieve the IWMSActiveMedia object.
            ActiveMedia = Playlist.CurrentMediaInformation;

            // Retrieve the IWMSActiveStreams object.
            ActiveStreams = ActiveMedia.Streams;
        }
    }
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

See Also

Previous Next