banner art

Previous Next


The ReadPlaylistFromDirectory method retrieves a playlist from an IWMSDirectory object.


  HRESULT ReadPlaylistFromDirectory(
  IWMSDirectory*  pDirectory,
  LPWSTR  pszwFilePattern,
  IXMLDOMDocument*  pPlaylist,
  IWMSPlaylistParserCallback*  pCallback,
  QWORD  qwContext



[in] Pointer to a directory object.


[in] Specifies the file pattern.


[in] Pointer to an IXMLDOMDocument interface to be used to store the interpreted playlist that can be read by the server.


[in] Pointer to an IWMSPlaylistParserCallback interface that is used by the plug-in to report the result of the ReadPlaylistFromDirectory method call back to the server.


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

If the method succeeds, the plug-in must return S_OK. To report an error, the plug-in can return any HRESULT other than S_OK. If the plug-in uses the IWMSEventLog interface to log error information directly to the Windows Event Viewer, it is recommended that it return NS_E_PLUGIN_ERROR_REPORTED. 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 interface to send custom error information to the Windows Event Viewer, returning NS_E_PLUGIN_ERROR_REPORTED stops the server from also logging to the event viewer. For more information about retrieving plug-in error information, see Identifying Plug-in Errors.


The ReadPlaylistFromDirectory method interprets the playlist contained in a directory and populates the IXMLDOMDocument interface. 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.

ForceRemove {15D0B1CE-E2C1-40E0-B705-219FD74F4375} = s 'SDKSamplePlaylistParser Class'
    ProgID = s 'SDKSamplePlaylistPlugin.SDKSamplePlaylistParser.9'
    VersionIndependentProgID = s 'SDKSamplePlaylistPlugin.SDKSamplePlaylistParser'
    ForceRemove 'Programmable'
    InprocServer32 = s '%MODULE%'
        val ThreadingModel = s 'Free'
    'TypeLib' = s '{F297F477-6FE2-4260-BE52-5F0CD960C780}'
    ForceRemove Properties
        val Name = s 'WMS SDK Sample Playlist Parser'
        val Author = s 'Microsoft Corporation'
        val Copyright = s 'Copyright (c).'
        val 'URL Suffix' = s '.playlist'
        val 'Input Format' = s '{7408CEB0-3A5A-41b6-A5EC-9A4E811C9673}'

Example Code

                        IWMSDirectory __RPC_FAR *pDirectory,
                        LPWSTR pszwFilePattern,
                        IXMLDOMDocument __RPC_FAR *pPlaylist,
                        IWMSPlaylistParserCallback __RPC_FAR *pCallback,
                        QWORD qwContext)
    IXMLDOMNode             *pWsxNode;
    IXMLDOMElement          *pPlayListMediaEntry;
    IXMLDOMElement          *pPlayListTopEntry;
    IXMLDOMNode             *pOldPlayListEntry;
    WMSDirectoryEntryInfo   EntryInfo;

    CComVariant             varValue;
    HRESULT                 hr;
    int                     i = 0;

    hr = pPlaylist->createNode(
    if ( FAILED(hr) ) goto EXIT;

    hr = pPlaylist->appendChild( pWsxNode, &pOldPlayListEntry );
    if ( FAILED(hr) ) goto EXIT;

    hr = pWsxNode->put_text( L"version='1.0'" );
    if ( FAILED(hr) ) goto EXIT;

    hr = pPlaylist->createElement( L"smil", &pPlayListTopEntry );
    if ( FAILED(hr) ) goto EXIT;

    pOldPlayListEntry = NULL;
    hr = pPlaylist->appendChild( pPlayListTopEntry, &pOldPlayListEntry );
    if ( FAILED(hr) ) goto EXIT;

    pDirectory->GetChildInfo(0, &EntryInfo);
    while( EntryInfo.pstrName != NULL )
        if( !(EntryInfo.dwFlags & WMS_DIRECTORY_ENTRY_IS_DIRECTORY) )
            hr = pPlaylist->createElement( L"media", &pPlayListMediaEntry );
            if ( FAILED(hr) ) goto EXIT;

            varValue = EntryInfo.pstrName;
            hr = pPlayListMediaEntry->setAttribute( L"src", varValue );
            if ( FAILED(hr) ) goto EXIT;

            hr = pPlayListTopEntry->appendChild( pPlayListMediaEntry, NULL );
            if ( FAILED(hr) ) goto EXIT;

        EntryInfo.pstrName = NULL;
        pDirectory->GetChildInfo(i, &EntryInfo);

    pCallback->OnReadPlaylist(hr, qwContext);

    // TODO: Release temporary COM objects.
    return( hr );


Header: wmsplaylistparser.h.

Library: WMSServerTypeLib.dll.

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

See Also

Previous Next