I am currently working on a plugin for winamp 2.81. I have a few API questions, i was wondering if anyone knew the answers to. Please note i am developing this plugin in VB using the GenWrapper which is available for Winamp.
I have managed to create a class that does everything i require (almost).
Here are some of the following functions i wrote:
Function WinAMP_GetPlaylistPosition() As Long
Dim ReturnPos As Long
ReturnPos = SendMessage(hWndWinAMP, WM_USER, 0, WA_GETPLAYPOS)
PositionInPlaylist = ReturnPos
WinAMP_GetPlaylistPosition = ReturnPos
End Function
This above functions get the position in 'tracks' of where i am in the playlist. This dosent locate the the highlighted item, it only returns what i double click.
I NEED to return the filename (complete path) of the items i click within the playlist.
So i managed to find a function in the winamp API that returned what was supposed to be the filename but it returned what looked like a pointer.
http://www.winamp.com/nsdn/winamp2x/dev/sdk/api.jhtml
I managed to locate the information i required on here.
Quote:
|
211 Retrieves (and returns a pointer in 'ret') a string that contains the filename of a playlist entry (indexed by 'data'). Returns NULL if error, or if 'data' is out of range.
|
This looked like what i require.
So i wrote this VB function:
Function WinAMP_GetFileName() As Long
Dim ReturnFile As Long
ReturnFile = SendMessage(hWndWinAMP, WM_USER, PositionInPlaylist, WA_GETPLAYLISTFILE)
WinAMP_GetFileName = ReturnFile
Debug.Print StringFromPointer(ReturnFile)
End Function
Public Function StringFromPointer(ByVal lPointer As Long) As String
'
Dim strTemp As String
Dim lRetVal As Long
'
'prepare the strTemp buffer
strTemp = String$(lstrlen(ByVal lPointer), 0)
'
'copy the string into the strTemp buffer
lRetVal = lstrcpy(ByVal strTemp, ByVal lPointer)
'
'return a string
If lRetVal Then StringFromPointer = strTemp
'
End Function
But it returns 'crap' basically. Not the filename it returns this:
MSVW‹ÿP‹}‹ð…öte‹Fƒx
I cant understand?? I then downloaded the .h file and decided to look through that to find some help.
It said that function ONLY works if its part as a plugin, at this current stage my program is external and not using GenWrapper, all i am doing is sending API calls to WinAMP anyhow. I CANT see why it needs to be a plugin...i have not had problems before getting data from programs using similar methods.
Anyway i checked out the API FAQ and here is what i found:
How do I get the filename (not title) of the current song?
First you must get the current track index from the playlist. Then you can get the filename.
int index = SendMessage(hwnd_winamp, WM_USER, 0, IPC_GETLISTPOS);
char *name = SendMessage(hwnd_winamp, WM_USER, index, IPC_GETPLAYLISTFILE);
This is what i have been doing but with no luck. Can anyone help me on this one? I am a skilled API coder but this one is killing me!
Its holding me back as well...
Thanks in advance folks.
I am awaure of the const' that exports the playlist direct to temp.m3u but i dont want to start playing around with files searching for filenames (even though its simple) i want a clean cut API solution.
- Dave