Indexing
and ASF file
The following code shows a simple
way to index and ASF file. Indexing could be needed if you
use the WmaWriter class
to obtain an ASF file and you plan using it in some kind of
devices (Pocket PC, for instance). When using custom writer
sinks, as in WmaWriter class, the resulting idexing isn't
as using file writer wink (as in IWMWriter.SetOutputFilename method). |
/// <summary>
/// /// /// </summary>
public class IndexerCallback : IWMStatusCallback
{
private System.Threading.ManualResetEvent m_Event = new System.Threading.ManualResetEvent(false);
public IndexerCallback()
{
}
public bool Finished
{
get { return m_Event.WaitOne(0, false); }
}
public bool WaitForCompletion(int Timeout)
{
return m_Event.WaitOne(Timeout, false);
}
public bool WaitForCompletion()
{
return m_Event.WaitOne();
}
#region IWMStatusCallback Members
public void OnStatus(Yeti.WMFSdk.WMT_STATUS Status,
System.IntPtr hr,
Yeti.WMFSdk.WMT_ATTR_DATATYPE dwType,
System.IntPtr pValue,
System.IntPtr pvContext)
{
switch(Status)
{
case WMT_STATUS.WMT_ERROR:
case WMT_STATUS.WMT_CLOSED:
m_Event.Set();
break;
}
}
#endregion
}
...
IWMIndexer Indexer = WM.CreateIndexer();
IndexerCallback Callback = new IndexerCallback();
(Indexer as IWMIndexer2).Configure(0, WMT_INDEXER_TYPE.WMT_IT_PRESENTATION_TIME,
IntPtr.Zero, IntPtr.Zero);
Indexer.StartIndexing("SomeFile.wma", Callback, IntPtr.Zero);
Callback.WaitForCompletion();
|