IWMSAnnouncementStreamFormats.Add (C#)

banner art

Previous Next

IWMSAnnouncementStreamFormats.Add (C#)

The Add method adds a URL or a file path to the IWMSAnnouncementStreamFormats collection.

  • Note   This method is available only on Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; and Windows Server 2008.

Syntax

  IWMSAnnouncementStreamFormats
  .Add(
  string  strFileName
);

Parameters

strFileName

[in] string containing the file name. Valid file names include those with an .asd extension.

Return Values

This method does not return a value.

If this method fails, it throws an exception.

Number Description
0x80070057 strFileName is an invalid argument. This can be returned if strFileName points to a directory or a playlist file.
0x00000002 The data source plug-in was not able to find the indicated file. This error is returned by the WMS File Data Source plug-in, but other plug-ins could return different error codes.
0x00000003 The path indicated by strFileName was not found.
0xC00D157EL The server was not able to find an enabled data source plug-in to access the indicated file.

Remarks

The Add method also parses the associated media file to extract stream format information. The IWMSBroadcastPublishingPoint.Announce method then updates the server configuration with that information. The IWMSBroadcastPublishingPoint.AnnounceToNSCFile method retrieves the stream format information from the server configuration and uses it to create a file that a client can use to receive and render a multicast broadcast.

If a file path is added, it must identify a Windows Media file, a multicast configuration (.nsc) file, or a stream format file from Windows Media Encoder. If a URL is added, it must identify a single source such as a live Windows Media Encoder stream or a Windows Media file on an upstream server. However, it is not recommended that you specify a server-side playlist. The format added to the collection will be that represented by only the first entry in the playlist.

Example Code

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

// Declare variables.
WMSServer                        Server;
IWMSPublishingPoints             PubPoints;
IWMSPublishingPoint              PubPoint;
IWMSBroadcastPublishingPoint     BCPubPoint;
IWMSAnnouncementStreamFormats    AnnounceStreamFormats;

string                           strFile;

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

    // Retrieve the IWMSPublishingPoints object.
    PubPoints = Server.PublishingPoints;

    // Retrieve each publishing point and retrieve the
    // IWMSBroadcastPublishingPoint object.
    for (int i = 0; i < PubPoints.Count; i++)
    {
        PubPoint = PubPoints[i];

        if (PubPoint.Type ==  
            WMS_PUBLISHING_POINT_TYPE.WMS_PUBLISHING_POINT_TYPE_BROADCAST)
        {
            BCPubPoint = (IWMSBroadcastPublishingPoint)PubPoint;

            // Retrieve the IWMSAnnouncementStreamFormats object.
            AnnounceStreamFormats = BCPubPoint.AnnouncementStreamFormats;

            // Add a file to the IWMSAnnoucementStreamFormats
            // object for multicast broadcasting.
            strFile = "file://c:\\wmpub\\wmroot\\welcome2.asf";
            AnnounceStreamFormats.Add(strFile);
            break;
        }
    }
}
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