public void GetMetadata() { try { String filename = @"E:\Music\Album Leaf\Vermillion .WMA"; ushort wStreamNum = 0; IWMMetadataEditor MetadataEditor; IWMHeaderInfo3 HeaderInfo3; ushort wAttributeCount; WMFSDKFunctions.WMCreateEditor(out MetadataEditor); MetadataEditor.Open(filename); HeaderInfo3 = (IWMHeaderInfo3)MetadataEditor; HeaderInfo3.GetAttributeCount(wStreamNum, out wAttributeCount); PrintListHeader(); for (ushort wAttribIndex = 0; wAttribIndex < wAttributeCount; wAttribIndex++) { WMT_ATTR_DATATYPE wAttribType; string pwszAttribName = null; byte[] pbAttribValue = null; ushort wAttribNameLen = 0; ushort wAttribValueLen = 0; HeaderInfo3.GetAttributeByIndex(wAttribIndex, ref wStreamNum, pwszAttribName, ref wAttribNameLen, out wAttribType, pbAttribValue, ref wAttribValueLen); pbAttribValue = new byte[wAttribValueLen]; pwszAttribName = new String((char)0, wAttribNameLen); HeaderInfo3.GetAttributeByIndex(wAttribIndex, ref wStreamNum, pwszAttribName, ref wAttribNameLen, out wAttribType, pbAttribValue, ref wAttribValueLen); PrintAttribute(wAttribIndex, wStreamNum, pwszAttribName, wAttribType, 0, pbAttribValue, wAttribValueLen); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
//------------------------------------------------------------------------------ // Name: ShowAttributes() // Desc: Displays all attributes for the specified stream. //------------------------------------------------------------------------------ bool ShowAttributes(string pwszFileName, ushort wStreamNum) { try { IWMMetadataEditor MetadataEditor; IWMHeaderInfo3 HeaderInfo3; ushort wAttributeCount; WMFSDKFunctions.WMCreateEditor(out MetadataEditor); MetadataEditor.Open(pwszFileName); HeaderInfo3 = ( IWMHeaderInfo3 )MetadataEditor; HeaderInfo3.GetAttributeCount(wStreamNum, out wAttributeCount); PrintListHeader(); for (ushort wAttribIndex = 0; wAttribIndex < wAttributeCount; wAttribIndex++) { WMT_ATTR_DATATYPE wAttribType; string pwszAttribName = null; byte[] pbAttribValue = null; ushort wAttribNameLen = 0; ushort wAttribValueLen = 0; HeaderInfo3.GetAttributeByIndex(wAttribIndex, ref wStreamNum, pwszAttribName, ref wAttribNameLen, out wAttribType, pbAttribValue, ref wAttribValueLen); pbAttribValue = new byte[wAttribValueLen]; pwszAttribName = new String((char)0, wAttribNameLen); HeaderInfo3.GetAttributeByIndex(wAttribIndex, ref wStreamNum, pwszAttribName, ref wAttribNameLen, out wAttribType, pbAttribValue, ref wAttribValueLen); PrintAttribute(wAttribIndex, wStreamNum, pwszAttribName, wAttribType, 0, pbAttribValue, wAttribValueLen); } } catch (Exception e) { Console.WriteLine(e.Message); return(false); } return(true); }