PDA

View Full Version : Get title/length of file not yet in the playlist.


thinktink
7th November 2010, 00:33
I'm in the middle of a plugin update and I need to know if it's at all possible to force/get/coax Winamp into retrieving the actual title/length of a file as it would be displayed in the playlist editor before it's been loaded into the playlist editor.

I searched the entire wa_ipc.h header for a solution. I only found two in my initial search. All the other ones that dealt with titles that I could find either only referenced hooking titles, changing titles, or getting titles already in the playlist. I could just be missing something though so I'm asking.

IPC_GET_BASIC_FILE_INFO <-- Didn't work, it just gave me NULL[title]/-1[length] for files not in the playlist yet.

IPC_GET_EXTENDED_FILE_INFO <--I couldn't any make sense of this one. What do I pass to the struct other than the full path and filename? If I do pass it the correct stuff to get it to work, would it still only work on files already in the playlist?

The reason why I need to get the title/length before putting it into the playlist editor is because I'm trying to manage playlists outside the pled (and inside the plugin only) and temporarily putting a file into the pled just to retrieve the title/length is not workable nor reliable at the moment. As a playlist file (M3U, PLS, or whatever) may or may not contain full meta info I would rather find an alternate source for the needed information instead of just skipping an otherwise valid playlist entry just because the info wasn't there. :( And since Winamp would be the ultimate authority on what it would look like in the pled anyways I would like Winamp to tell me instead of trying to read the file manually (and because I don't know HOW to read every single stink'n kind of media file type on the face of the planet like Winamp basically does! :o )

I searched the forums but the search results gave me pages and pages of stuff that was not relevant to my current question.

If this question was already answered I apologize in advance and please post a link to the answer.

As my avatar suggests, I've been banging my head on my desk for a while now. It's starting to hurt. :p

Thanks in advance


1. Sorry - no matches. Please try some different terms.

The following words are either very common, too long, or too short and were not included in your search : IPC_GET_EXTENDED_FILE_INFO

DrO
7th November 2010, 09:47
wchar_t* GetExtendedFileInfo(wchar_t* file, const wchar_t* field){
extendedFileInfoStructW exFIS;
static wchar_t metadata[MAX_PATH];
metadata[0] = 0;
exFIS.filename = file;
exFIS.ret = metadata;
exFIS.retlen = sizeof(metadata);
// "ARTIST", "TITLE", "ALBUM", "TRACK", "YEAR", "GENRE", "COMMENT"
exFIS.metadata = field;
if(SendMessage(plugin.hwndParent,WM_WA_IPC,(WPARAM)&exFIS,IPC_GET_EXTENDED_FILE_INFOW)){
// can do stuff since data was received
return metadata;
}
return 0;
}


wchar_t* myTagFuncW(const wchar_t *tag, void *p){
static wchar_t retBuf[2048];
retBuf[0] = 0;
if(!lstrcmpiW(tag,L"plpos")){
StringCchPrintf(retBuf,2048,L"%d",SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_GETLISTPOS)+1);
}
else{
// this is a good fallback so that any tags not implemented here should be filled in
// though using the ML interface will provide a faster method if the data has already
// been loaded from the files (since the ML caches it all in memory).
wchar_t* ret = GetExtendedFileInfo((wchar_t*)p,tag);
if(ret) lstrcpyn(retBuf,ret,2048);
}
return (retBuf[0]?retBuf:0);
}


wchar_t* GetFormattedTitleFromWinamp(wchar_t* spec, void* p){
waFormatTitleExtended fmt_title;
static wchar_t temp[2048];
temp[0] = 0;
fmt_title.useExtendedInfo = 1;
fmt_title.spec = spec; // pass as 0 use the default atf as defined by winamp
fmt_title.TAGFUNC = myTagFuncW;
fmt_title.TAGFREEFUNC = 0;
fmt_title.out = temp;
fmt_title.out_len = 2048;
fmt_title.filename = (wchar_t*)(fmt_title.p = p);
SendMessage(plugin.hwndParent,WM_WA_IPC,(WPARAM)&fmt_title,IPC_FORMAT_TITLE_EXTENDED);
return temp;
}this is what i use to get titles formatted as the playlist editor shows using GetFormattedTitleFromWinamp(..) - can't remember what client version is needed as a minimum though i know it's all fine for 5.5+. is what i use in jtfe and a few other plug-ins so you can probably remove the plpos aspect as that's non-standard in the playlist editor atf.

to get the length, you should just need to use the GetExtendedFileInfo(..) function passing 'length' as the 'field' value though i can't double-check that at the moment so i might be wrong, heh.

-daz

thinktink
7th November 2010, 19:05
Thank you and yeah, I just had myTagFuncW just return 0 and it worked.

"LENGTH" works but I had to convert the return value from thousandths-of-a-second.

I am assuming that as I cannot find an Ansi version of IPC_FORMAT_TITLE_EXTENDED in the header this is implemented as unicode onry?

DrO
7th November 2010, 19:23
IPC_FORMAT_TITLE is the older ansi equivalent though it doesn't have the built-in means to use the standard atf string - requires manually reading the setting from the ini file (though if i remember correctly it isn't saved to file until Winamp is closed or a force settings save happens).

it really comes down to what Winamp version you want to support from as to what to do. personally i don't see any benefit in going for pre-5.5 unless there's a good reason (as there's often a lot more version checking on certain apis when going from 5.2 to 5.5).

-daz