IWMSCacheProxyServerCallback.OnDownloadContentProgress (Visual Basic .NET)

banner art

Previous Next

IWMSCacheProxyServerCallback.OnDownloadContentProgress (Visual Basic .NET)

The OnDownloadContentProgress method is called by the server when each media item identified in a playlist has been downloaded.

Syntax

  

Parameters

lHr

[in] Integer 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

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

Public Sub OnDownloadContentProgress(ByVal lHr As Integer, _
                                     ByVal opCode As WMS_RECORD_PROGRESS_OPCODE, _
                                     ByVal ArchiveContext As IWMSContext, _
                                     ByVal varContext As Object) _
  Implements IWMSCacheProxyServerCallback.OnDownloadContentProgress

    Dim Buffer As INSSBuffer
    Dim CacheFile As String
    Dim ci As ContentInfo
    Dim strCDL As String
    Dim Item As PlaylistItem

    Try
        ' Retrieve the name of the download file.
        ArchiveContext.GetAndQueryIUnknownValue(WMSDefines.WMS_ARCHIVE_CONTENT_DESCRIPTION_LIST_BUFFER, _
                                                WMSDefines.WMS_ARCHIVE_CONTENT_DESCRIPTION_LIST_BUFFER_ID, _
                                                GetType(INSSBuffer).GUID, _
                                                Buffer, _
                                                0)
        ArchiveContext.GetStringValue(WMSDefines.WMS_ARCHIVE_FILENAME, _
                                      WMSDefines.WMS_ARCHIVE_FILE_SIZE_ID, _
                                      CacheFile, _
                                      0)

        ' Retrieve the user-defined ContentInfo object
        ' from the varContext parameter. The ContentInfo
        ' class is used to describe an item of cached content.
        ci = varContext

        ' If this is not a playlist, assign the file
        ' name to the cache URL. GetStringFromNSSBuffer()
        ' is user-defined.
        strCDL = GetStringFromNSSBuffer(Buffer)
        If (ci.ContentType And 2) = 0 Then
            ci.CDLData = strCDL
            ci.CacheUrl = CacheFile
        Else
            ' This is a playlist.
            Item = New PlaylistItem()
            Item.CacheUrl = CacheFile
            Item.CDLData = strCDL
            ci.CDL.Add(Item)

        End If

    Catch
        Throw New COMException()
    End Try

End Sub

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