IWMSPlaylistParser.ReadPlaylistFromDirectory (C#)

banner art

Previous Next

IWMSPlaylistParser.ReadPlaylistFromDirectory (C#)

The ReadPlaylistFromDirectory method retrieves a playlist from an IWMSDirectory object.





IWMSDirectory object containing the directory to read.


string containing the file pattern to read.


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


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


ulong 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.


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.

In order 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 string strClassId = "E2D2CA7B-0B32-460f-95B3-11BD535C709B";
public const string strPlgName = "CSharp Playlist Parser Plugin";
public const string strSubKey1 = "SOFTWARE\\Microsoft\\Windows Media\\Server\\RegisteredPlugins\\Playlist Parser\\{" + strClassId + "}";
public const string strSubKey2 = "CLSID\\{" + strClassId + "}\\Properties";

public static void RegisterFunction(Type t)
        RegistryKey regHKLM = Registry.LocalMachine;
        regHKLM = regHKLM.CreateSubKey(strSubKey1);
        regHKLM.SetValue(null, strPlgName);

        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}");
        // TODO: Handle exceptions.

Example Code

void IWMSPlaylistParser.ReadPlaylistFromDirectory(
    IWMSDirectory pDirectory,
    string pszwFilePattern,
    IXMLDOMDocument pPlaylist,
    IWMSPlaylistParserCallback pCallback,
    ulong qwContext)
    WMSDirectoryEntryInfo EntryInfo;
    IXMLDOMNode pNode;
    IXMLDOMElement pSMIL;
    IXMLDOMElement pElement;
    int i = 0;

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

        pSMIL = pPlaylist.createElement("smil");

        pDirectory.GetChildInfo(Convert.ToUInt32(i), out EntryInfo);
        while( !EntryInfo.pstrName.Equals("") )
            if( (Convert.ToInt32(EntryInfo.dwFlags) &
                pElement = pPlaylist.createElement("media");
                pElement.setAttribute("src", EntryInfo.pstrName);

            pDirectory.GetChildInfo(Convert.ToUInt32(i), out EntryInfo);

        pCallback.OnReadPlaylist(S_OK, qwContext);
        pCallback.OnReadPlaylist(E_FAIL, qwContext);


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