Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The ReadPlaylistFromDirectory method retrieves a playlist from an IWMSDirectoryIWMSDirectory Object (C#).
void IWMSPlaylistParser.ReadPlaylistFromDirectory(
IWMSDirectory pDirectory,
string pszwFilePattern,
IXMLDOMDocument pPlaylist,
IWMSPlaylistParserCallback pCallback,
ulong qwContext
);
Arguments
IWMSDirectory object containing the directory to read. |
|
string containing the file pattern to read. |
|
IXMLDOMDocumentIXMLDOMDocument Object (C#) in which to store the interpreted playlist that can be read by the server. |
|
IWMSPlaylistParserCallbackIWMSPlaylistParserCallback Object (C#) 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 Value
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 IWMSEventLogIWMSEventLog Object (C#) 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.
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";
[ComRegisterFunctionAttribute]
public static void RegisterFunction(Type t)
{
try
{
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}");
}
catch
{
// TODO: Handle exceptions.
}
}
Example
void IWMSPlaylistParser.ReadPlaylistFromDirectory(
IWMSDirectory pDirectory,
string pszwFilePattern,
IXMLDOMDocument pPlaylist,
IWMSPlaylistParserCallback pCallback,
ulong qwContext)
{
WMSDirectoryEntryInfo EntryInfo;
IXMLDOMNode pNode;
IXMLDOMElement pSMIL;
IXMLDOMElement pElement;
int i = 0;
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), out EntryInfo);
while( !EntryInfo.pstrName.Equals("") )
{
if( (Convert.ToInt32(EntryInfo.dwFlags) &
(int)WMS_DIRECTORY_ENTRY_FLAGS.WMS_DIRECTORY_ENTRY_IS_DIRECTORY) == 0 )
{
pElement = pPlaylist.createElement("media");
pElement.setAttribute("src", EntryInfo.pstrName);
pSMIL.appendChild(pElement);
}
i++;
pDirectory.GetChildInfo(Convert.ToUInt32(i), out EntryInfo);
}
pCallback.OnReadPlaylist(S_OK, qwContext);
}
catch
{
pCallback.OnReadPlaylist(E_FAIL, qwContext);
}
}
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.