jimbo22
Joined: 02 Mar 2006
Posts: 1
|
Posted:
Thu Mar 02, 2006 9:18 pm Post subject:
having trouble reading wma files with IWMReader in c# ... |
|
|
I want to be able to read tags of wma files located on the internet. I expect that opening the file using the WMCreateReader method and querying the object for the IWMHeaderInfo interface should do the trick. I am able to open the file, but all subsequent calls to the object fails with a E_NOINTERFACE error. What am I doing wrong? (See code below)
Comment on the code:
The C# version of the wmsdkidl interface definitions that I'm using was found here: http://www.codeproject.com/cs/media/ManWMF.asp
Let me know if you suspect that the problem originates from the interface definitions and I'll post them here.
------------------------------------------------------------------------------------
class WMPTest : IWMReaderCallback
{
[DllImport("WMVCore.dll",
EntryPoint = "WMCreateReader",
SetLastError = true,
CharSet = CharSet.Unicode,
ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
public static extern uint WMCreateReader(
[In, MarshalAs(UnmanagedType.Interface)] object
pUnkReserved, // Always null.
[In] WMT_RIGHTS dwRights,
[Out, MarshalAs(UnmanagedType.Interface)] out IWMReader
ppReader
);
private IWMReader reader;
public void open(string url)
{
WMCreateReader(null, WMT_RIGHTS.WMT_RIGHT_PLAYBACK, out reader);
reader.Open(url, this, null);
}
public uint OnSample(uint dwOutputNum, ulong cnsSampleTime, ulong cnsSampleDuration, uint dwFlags, INSSBuffer pSample, object pvContext)
{
return 0;
}
public uint OnStatus(WMT_STATUS Status, uint hResult, WMT_ATTR_DATATYPE dwType, byte[] pValue, object pvContext)
{
if (((int)hResult) < 0)
throw new Exception("failed!");
if (Status == WMT_STATUS.WMT_OPENED)
{
//IWMHeaderInfo info = (IWMHeaderInfo)reader;
reader.Start(0, 100, 100, null); //this call fails with E_NOINTERFACE
}
return 0;
}
}
------------------------------------------------------------------------------------
|
|