Configuring Your New On-Demand Publishing Point

After creating a new publishing point for your content, be sure that it is properly configured, based on your needs. Besides the normal publishing point configuration, an on-demand publishing point has some extra configuration options. The following Visual Basic, C#, and C++ examples show how you might configure your publishing point. You can tailor the configuration to your needs.

Visual Basic .NET Example

Imports Microsoft.WindowsMediaServices.Interop
Imports System.Runtime.InteropServices

' Declare variables.
Dim Server As WMSServer
Dim ODPubPoint As IWMSOnDemandPublishingPoint

Try
    ' Create the WMSServer object.
    Server = New WMSServer()

    ' Retrieve an on-demand publishing point.
    ODPubPoint = Server.PublishingPoints.Item("NewPubPointII")

    ' Set the publishing point to enable content to be
    ' cached before sending it to a client.
    ODPubPoint.AllowContentCaching = True

    ' Set the publishing point to prevent client access
    ' to files by using wildcard characters (for example, *.asf).
    ODPubPoint.EnableClientWildcardDirectoryAccess = False

    ' Set the publishing point to prevent clients from
    ' downloading and storing server content locally.
    ODPubPoint.EnableDownload = False

    ' Set the client content download rate to unlimited.
    ODPubPoint.DownloadBandwidth = 0

Catch errCom As COMException
    ' TODO: Handle COM exceptions.
Catch err As Exception
    ' TODO: Exception handler goes here.
Finally
    ' TODO: Clean-up code goes here.
End Try

C# Example

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

// Declare variables.
WMSServer Server;
IWMSOnDemandPublishingPoint ODPubPoint;

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

    // Retrieve an on-demand publishing point.
    ODPubPoint = 
(IWMSOnDemandPublishingPoint)Server.PublishingPoints["NewPubPointII"];

    // Set the publishing point to enable content to be
    // cached before sending it to a client.
    ODPubPoint.AllowContentCaching = true;

    // Set the publishing point to prevent client access
    // to files by using wildcard characters (for example, *.asf).
    ODPubPoint.EnableClientWildcardDirectoryAccess = false;

    // Set the publishing point to prevent clients from
    // downloading and storing server content locally.
    ODPubPoint.EnableDownload = false;

    // Set the client content download rate to unlimited.
    ODPubPoint.DownloadBandwidth = 0;

}
catch (COMException comExc)
{
    // TODO: Handle COM exceptions.
}
catch (Exception exc) 
{
    // TODO: Handle exceptions.
}
finally 
{
    // Clean-up code goes here.
}

C++ Example

#include <windows.h>
#include <atlbase.h>    // Includes CComBSTR.
#include "wmsserver.h"

// Declare variables and interfaces.
IWMSServer                  *pServer;
IWMSPublishingPoints        *pPubPoints;
IWMSPublishingPoint         *pPubPoint;
IWMSOnDemandPublishingPoint *pODPubPoint;

HRESULT         hr;
CComVariant     varName;

// Initialize the COM library and retrieve a pointer
// to an IWMSServer interface.
hr = CoInitialize(NULL);
hr = CoCreateInstance(CLSID_WMSServer,
                      NULL,
                      CLSCTX_ALL,
                      IID_IWMSServer,
                      (void **)&pServer);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to the IWMSPublishingPoints interface.
hr = pServer->get_PublishingPoints(&pPubPoints);
if (FAILED(hr)) goto EXIT;

// Retrieve a pointer to a publishing point.
varName = L"NewPubPointII";
hr = pPubPoints->get_Item(varName, &pPubPoint);

// Query the IWMSOnDemandPublishingPoint interface from
// the publishing point.
hr = pPubPoint->QueryInterface(IID_IWMSOnDemandPublishingPoint,
                              (void **)&pODPubPoint);

// Set the publishing point to allow content to be
// cached before sending it to a client.
hr = pODPubPoint->put_AllowContentCaching(VARIANT_TRUE);
if (FAILED(hr)) goto EXIT;

// Set the publishing point to prevent client access
// to files by using wildcard characters (for example, *.asf).
hr = pODPubPoint->put_EnableClientWildcardDirectoryAccess(VARIANT_FALSE);
if (FAILED(hr)) goto EXIT;

// Set the publishing point to prevent clients from
// downloading and storing server content locally.
hr = pODPubPoint->put_EnableDownload(VARIANT_FALSE);
if (FAILED(hr)) goto EXIT;

// Set the client content download rate to unlimited.
hr = pODPubPoint->put_DownloadBandwidth(0);
if (FAILED(hr)) goto EXIT;

EXIT:
    // TODO: Release temporary COM objects and uninitialize COM.

See Also

Reference

IWMSOnDemandPublishingPoint Interface

IWMSOnDemandPublishingPoint Object (C#)

IWMSOnDemandPublishingPoint Object (Visual Basic .NET)

Concepts

Publishing Content On Demand