IWMSActiveMedia.Live (C#)

banner art

Previous Next

IWMSActiveMedia.Live (C#)

The Live property retrieves a Boolean value that indicates whether the media element originates from a live source.

Syntax

  bool = IWMSActiveMedia.Live;

Property Value

A bool that indicates whether the media element is live.

Remarks

This property is read-only. Windows Media Player for Windows XP and later client versions return this property correctly; however older client versions always report content as being live.

Example Code

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;

            // Retrieve a Boolean value indicating whether
            // the stream is live.
            if (ActiveMedia.Live == true)
            {
            // TODO: Handle any live stream specific tasks here.
            }
        }
    }
}
catch (COMException comExc) {
    // TODO: Handle COM exceptions.
}
catch (Exception e) {
    // TODO: Handle exceptions.
}

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003 family, Windows Server 2008 family.

See Also

Previous Next