IWMSPlaylistParser.ReadPlaylistFromDirectory (Visual Basic .NET)

banner art

Previous Next

IWMSPlaylistParser.ReadPlaylistFromDirectory (Visual Basic .NET)

The ReadPlaylistFromDirectory method retrieves a playlist from an IWMSDirectory object.

Syntax

  

Parameters

pDirectory

IWMSDirectory object containing the directory to read.

pszwFilePattern

String containing the file pattern to read.

pPlaylist

IXMLDOMDocument object to be used to store the interpreted playlist that can be read by the server.

pCallback

IWMSPlaylistParserCallback object that is used by the plug-in to report the result of the ReadPlaylistFromDirectory method call back to the server.

qwContext

UInt64 containing a value defined by the server to identify which call to ReadPlaylistFromDirectory the plug-in is responding to when it calls IWMSPlaylistParserCallback.OnReadPlaylist. You must pass this value back unaltered when you call OnReadPlaylist.

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.

Remarks

The ReadPlaylistFromDirectory method interprets the playlist contained in a directory and populates the IXMLDOMDocument object. This method is implemented by the plug-in and called by the server.

To register a custom directory playlist parser plug-in you must specify a value of "{7408CEB0-3A5A-41b6-A5EC-9A4E811C9673}" for the "Input Format" property in the plug-in's registry settings. The following example shows how to register a directory playlist parser plug-in.

Public Const ClassId As String = "096434BC-16C6-4c94-8356-28FCB7BC87AA"
Public Const strPlgName As String = "VB.NET Playlist Parser Plugin"
Public Const strSubKey1 As String = "SOFTWARE\\Microsoft\\Windows Media\\Server\\RegisteredPlugins\\Playlist Parser\\{" + ClassId + "}"
Public Const strSubKey2 As String = "CLSID\\{" + ClassId + "}\\Properties"

<ComRegisterFunctionAttribute()> _
Shared Sub RegisterFunction(ByVal t As Type)
    Try
        Dim regHKLM As RegistryKey
        regHKLM = Registry.LocalMachine
        regHKLM = regHKLM.CreateSubKey(strSubKey1)
        regHKLM.SetValue(Nothing, strPlgName)

        Dim regHKCR As RegistryKey
        regHKCR = Registry.ClassesRoot
        regHKCR = regHKCR.CreateSubKey(strSubKey2)
        regHKCR.SetValue("Name", strPlgName)
        regHKCR.SetValue("Author", "Plugin Author")
        regHKCR.SetValue("CopyRight", "Copyright (c).")
        regHKCR.SetValue("URL Suffix", ".dj")
        regHKCR.SetValue("Description", "This plugin parses .dj files.")
        regHKCR.SetValue("Input Format", "{7408CEB0-3A5A-41b6-A5EC-9A4E811C9673}")

    Catch e As Exception
        ' TODO: Handle exceptions.
    End Try
End Sub

Example Code

Public Sub ReadPlaylistFromDirectory( _
    ByVal pDirectory As IWMSDirectory, _
    ByVal pszwFilePattern As String, _
    ByVal pPlaylist As interop_msxml.IXMLDOMDocument, _
    ByVal pCallback As IWMSPlaylistParserCallback, _
    ByVal qwContext As System.UInt64) _
    Implements IWMSPlaylistParser.ReadPlaylistFromDirectory

    Dim EntryInfo As WMSDirectoryEntryInfo
    Dim pNode As IXMLDOMNode
    Dim pSMIL As IXMLDOMElement
    Dim pElement As IXMLDOMElement
    Dim i As Integer

    Try
        pNode = pPlaylist.createNode( _
                    tagDOMNodeType.NODE_PROCESSING_INSTRUCTION, "wsx", "")
        pPlaylist.appendChild(pNode)
        pNode.text = "version='1.0'"

        pSMIL = pPlaylist.createElement("smil")
        pPlaylist.appendChild(pSMIL)

        pDirectory.GetChildInfo(Convert.ToUInt32(i), EntryInfo)
        While StrComp(EntryInfo.pstrName, vbNullString) > 0
            If Not (Convert.ToInt32(EntryInfo.dwFlags) And _
          WMS_DIRECTORY_ENTRY_FLAGS.WMS_DIRECTORY_ENTRY_IS_DIRECTORY) Then
                pElement = pPlaylist.createElement("media")
                pElement.setAttribute("src", EntryInfo.pstrName)
                pSMIL.appendChild(pElement)
            End If

            i = i + 1
            pDirectory.GetChildInfo(Convert.ToUInt32(i), EntryInfo)
        End While

        pCallback.OnReadPlaylist(S_OK, qwContext)
    Catch e As Exception
        pCallback.OnReadPlaylist(E_FAIL, qwContext)
    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