Share via


IWMSActiveMedia Object (C#)

banner art

Previous Next

IWMSActiveMedia Object (C#)

The IWMSActiveMedia object provides information about the currently active media element in a playlist. A media element can include both audio and video streams.

The IWMSActiveMedia object exposes the following properties and methods.

Property Description
Duration Retrieves the total length of the media element, in milliseconds.
Live Retrieves a Boolean value that indicates whether the media element originates from a live source.
Streams Retrieves an IWMSActiveStreams object that contains a collection of the media streams that make up the active media element.
TotalPackets Retrieves the total number of data packets contained in the active media element.
Method Description
GetProperty Retrieves a specific property from the active media element.

Example Code

The following example illustrates how to retrieve an IWMSActiveMedia object.

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

// Declare variables.
WMSServer         Server;
IWMSActiveMedia   ActiveMedia;
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 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;
        }
    }
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

See Also

Previous Next