private void GetTitle()
{
extendedFileInfoStruct efi;
int pos = SendMessage(pluginWindow, WM_WA_IPC, 0, IPC_GETLISTPOS);
unsafe
{
sbyte* fileName = (sbyte*)SendMessage(pluginWindow, WM_WA_IPC, pos, IPC_GETPLAYLISTFILE);
if (fileName == null)
return;
string theTitre = new string(fileName);
if ((!(theTitre.Equals(theOldTitre))) || (thePrefs.SigChanged == true) || (winampStopped == true))
{
theOldTitre = theTitre;
efi.filename = fileName;
efi.retlen = 255;
atts = getID3Attributes(&efi);
SongChangedEventArgs e = new SongChangedEventArgs(atts);
if (SongChanged != null)
SongChanged(this, e);
}
theTitre = null;
}
}
private unsafe NameValueCollection getID3Attributes(extendedFileInfoStruct* efi)
{
NameValueCollection coll = new NameValueCollection();
StringEnumerator attrsEnumerator = attributes.GetEnumerator();
sbyte* retBuffer = (sbyte*)Marshal.AllocHGlobal(256).ToPointer();
while (attrsEnumerator.MoveNext())
{
byte[] tmpMeta = Encoding.ASCII.GetBytes(attrsEnumerator.Current.ToCharArray());
efi->ret = retBuffer;
fixed (byte* metadata = &tmpMeta[0])
efi->metadata = metadata;
SendMessage(pluginWindow, WM_WA_IPC, new IntPtr(efi).ToInt32(), IPC_GET_EXTENDED_FILE_INFO);
string strAttr = new String(retBuffer);
coll.Add(attrsEnumerator.Current, strAttr);
}
Marshal.FreeHGlobal((IntPtr)retBuffer);
return coll;
}