Compartir a través de


IWMSCacheProxyServerCallback.OnDownloadContentFinished (C#)

The OnDownloadContentFinished method is called by the server to respond when a cache plug-in calls IWMSCacheProxyServer.DownloadContent. The OnDownloadContentFinished method is called when the content has been completely downloaded. If the requested content is a server-side playlist, this method is called only after all of the playlist entries have been downloaded. The IWMSCacheProxyServerCallback::OnDownloadContentProgress method is called every time a playlist entry has been downloaded.

void IWMSCacheProxyServerCallback.OnDownloadContentFinished(
  int lHr,
  Object[] psaArchiveContexts,
  object varContext
);

Arguments

[in] int indicating whether the call to IWMSCacheProxyServer.DownloadContent succeeded.

[in] Array of objects containing one or more archive contexts. When a single on-demand file is downloaded, the array will contain one context. When multiple items in a playlist are downloaded, the array will contain a context for each item, and the first entry will contain an archive context describing the entire playlist.

[in] object containing a value defined by the plug-in when it called IWMSCacheProxyServer.DownloadContent. For example, your plug-in can use this parameter to persist state information. The server does not alter this value and passes it back when calling OnDownloadContentFinished.

Return Value

This method does not return a value. To report an error, the plug-in can throw a COMException object to the server. If the plug-in uses the IWMSEventLogIWMSEventLog Object (C#) to log error information, it is recommended that it throw NS_E_PLUGIN_ERROR_REPORTED (0xC00D157D). Typically, the server attempts to make plug-in error information available to the server object model, the Windows Event Viewer, and the troubleshooting list in the details pane of the Windows Media Services MMC. However, if the plug-in uses the IWMSEventLog object to send custom error information to the Windows Event Viewer, throwing NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about plug-in error information, see Identifying Plug-in Errors.

Example

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

void IWMSCacheProxyServerCallback.OnDownloadContentFinished(
                                    int lHr,
                                    object[] psaArchiveContexts,
                                    object varContext)
{
  try
  {
    // The plug-in's call to IWMSCacheProxyServer.DownloadContent
    // succeeded.
    if(lHr==0)
    {
      // Retrieve the user-defined ContentInfo object from 
      // the varContext parameter.
      ContentInfo ci = (ContentInfo)varContext;

      if(psaArchiveContexts.Length!=0) 
      {
        // The content is not a playlist.
        if((ci.ContentType & 2)==0)
        {
          IWMSContext ArchiveContext = (IWMSContext)psaArchiveContexts.GetValue(0);
          // Retrieve the file name. The server can change
          // file names to avoid a naming collision.
          string CacheFile;
          ArchiveContext.GetStringValue(WMSDefines.WMS_ARCHIVE_FILENAME,
                                        WMSDefines.WMS_ARCHIVE_FILENAME_ID,
                                        out CacheFile,
                                        0);
          ci.CacheUrl = CacheFile;
        }
        // Save the playlist.
        else
        {
          // Call the user-defined function, SavePlaylist().
          SavePlaylist(ci);
        }
        UpdateTable(ci);
      }
    }
  }

  catch(Exception e)
  {
    throw new COMException();
  }

    return;
}

Requirements

Reference: Add a reference to Microsoft.WindowsMediaServices.

Namespace: Microsoft.WindowsMediaServices.Interop.

Assembly: Microsoft.WindowsMediaServices.dll.

Library: WMSServerTypeLib.dll.

Platform: Windows Server 2003, Enterprise Edition; Windows Server 2003, Datacenter Edition; Windows Server 2008.

See Also

Concepts

IWMSCacheProxyServerCallback Object (C#)