IWMSCacheProxyServerCallback.OnDownloadContentProgress (C#)
Previous | Next |
IWMSCacheProxyServerCallback.OnDownloadContentProgress (C#)
The OnDownloadContentProgress method is called by the server to respond when a cache plug-in calls IWMSCacheProxyServer::DownloadContent. The OnDownloadContentProgress method is called every time content is downloaded. Therefore, it is called every time an entry in a playlist has been downloaded. However, it is not guaranteed to be called in the order of the entries.
Syntax
Parameters
lHr
[in] int indicating whether the call to IWMSCacheProxyServer.DownloadContent.
opCode
[in] Member of the WMS_RECORD_PROGRESS_OPCODE enumeration type indicating the state of the download. This must be one of the following values.
Value | Description |
WMS_RECORD_PROGRESS_ARCHIVE_STARTED | The requested content is being saved. |
WMS_RECORD_PROGRESS_ARCHIVE_FINISHED | The archiving process has been completed. |
pArchiveContext
[in] IWMSContext object containing a pointer to an INSSBuffer object that contains the serialized metadata for the media item being downloaded. The metadata must be persisted by the plug-in. For more information, see Downloading Content.
varContext
[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 OnDownloadContentProgress.
Return Values
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 IWMSEventLog object 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 Code
using Microsoft.WindowsMediaServices.Interop; using System.Runtime.InteropServices; void IWMSCacheProxyServerCallback.OnDownloadContentProgress( int lHr, WMS_RECORD_PROGRESS_OPCODE opCode, IWMSContext pArchiveContext, object varContext) { try { // The call to IWMSCacheProxyServer.DownloadContentProgress // succeeded. if(lHr==0) { // The archive has been started. if(opCode==WMS_RECORD_PROGRESS_OPCODE.WMS_RECORD_PROGRESS_ARCHIVE_STARTED) { // Retrieve the name of the download file. INSSBuffer NSBuffer=null; Guid guid = typeof(INSSBuffer).GUID; Object obj; pArchiveContext.GetAndQueryIUnknownValue(WMSDefines.WMS_ARCHIVE_CONTENT_DESCRIPTION_LIST_BUFFER, WMSDefines.WMS_ARCHIVE_CONTENT_DESCRIPTION_LIST_BUFFER_ID, ref guid, out obj , 0); NSBuffer = (INSSBuffer)obj; string CacheFile; pArchiveContext.GetStringValue(WMSDefines.WMS_ARCHIVE_FILENAME, WMSDefines.WMS_ARCHIVE_FILENAME_ID, out CacheFile, 0); // Retrieve the user-defined ContentInfo object // from the varContext parameter. ContentInfo ci = (ContentInfo)varContext; // If this is not a playlist, assign the file // name to the cache URL. string s = GetStringFromNSSBuffer(NSBuffer); if((ci.ContentType & 2)==0) // not a playlist { ci.CDLData = s; ci.CacheUrl = CacheFile; } // This is a playlist. else { PlaylistItem Item = new PlaylistItem(); Item.CacheUrl = CacheFile; Item.CDLData = s; ci.CDL.Add((object)Item); } } } } 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
Previous | Next |