wa22guy Posted October 16, 2004 Share Posted October 16, 2004 Anyone know how to get the file location of the current playing song using C# for Winamp? [Edit: Please edit my topic to add C# at the top] Link to comment Share on other sites More sharing options...
0 Litespeed Posted October 27, 2004 Share Posted October 27, 2004 Anyone know how to get the file location of the current playing song using C# for Winamp?[Edit: Please edit my topic to add C# at the top] 584744992[/snapback] Here's roughly the steps I use: 1. Send a WM_USER, 0, 120 message to Winamp which saves the playlist to winamp.m3u 2. read the winamp.m3u file in as a text file into a datatable 3. Send a WM_USER, 0, 125 message to winamp to get the current track ID 4. Look up that ID in the playlist datable 5. The data will be the filename Link to comment Share on other sites More sharing options...
0 wa22guy Posted October 29, 2004 Author Share Posted October 29, 2004 Here's roughly the steps I use:1. Send a WM_USER, 0, 120 message to Winamp which saves the playlist to winamp.m3u 2. read the winamp.m3u file in as a text file into a datatable 3. Send a WM_USER, 0, 125 message to winamp to get the current track ID 4. Look up that ID in the playlist datable 5. The data will be the filename 584814762[/snapback] Great idea! I'll use it. Thanks! Link to comment Share on other sites More sharing options...
0 Simon Thulbourn Posted October 29, 2004 Share Posted October 29, 2004 There is another way... SendMessage(hwndWinamp, WM_USER, 125, NULL); this will return the file name and full path of the current track Link to comment Share on other sites More sharing options...
0 judge Posted October 29, 2004 Share Posted October 29, 2004 Can someone provide a link where I can get more information on controlling winamp in this way? I did wander over to winamp.com but couldn't find anything of this sort. Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted October 29, 2004 Share Posted October 29, 2004 Can someone provide a link where I can get more information on controlling winamp in this way? I did wander over to winamp.com but couldn't find anything of this sort. 584827046[/snapback] Download the SDK. Then look at the gen_ml directory for headers for IPC(that's (I)nter(P)rocess ©ommunication) calls. http://www.winamp.com/nsdn/winamp/sdk/ Link to comment Share on other sites More sharing options...
0 wa22guy Posted October 29, 2004 Author Share Posted October 29, 2004 There is another way... SendMessage(hwndWinamp, WM_USER, 125, NULL); this will return the file name and full path of the current track 584826667[/snapback] This doesn't work in C# though does it? Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted October 29, 2004 Share Posted October 29, 2004 Download the SDK. Then look at the gen_ml directory for headers for IPC(that's (I)nter(P)rocess ?ommunication) calls.http://www.winamp.com/nsdn/winamp/sdk/ 584827589[/snapback] Oops. Look at the wa_ipc.h file in the winamp directory of the sdk. Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted October 29, 2004 Share Posted October 29, 2004 This doesn't work in C# though does it? 584828715[/snapback] You need to import SendMessage and get the right constant for the WM_USER message. [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); const int WM_USER = 0x0400; Link to comment Share on other sites More sharing options...
0 wa22guy Posted October 29, 2004 Author Share Posted October 29, 2004 You need to import SendMessage and get the right constant for the WM_USER message. [DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); const int WM_USER = 0x0400; 584828961[/snapback] The problem is that SendMessage returns an int, so how can I get the playing file location in a string? Link to comment Share on other sites More sharing options...
0 azcodemonkey Posted October 29, 2004 Share Posted October 29, 2004 The problem is that SendMessage returns an int, so how can I get the playing file location in a string? 584829048[/snapback] You still need to write the playlist to disk, and the int returned is the position in the playlist. It's probably the most foolproof way to do it. However, if you can't get a handle to the Winamp window, it won't work in any way. The handle to the window won't exist if it is set to show in tray only or minimized to tray. If it is shown in the taskbar, you could use the .MainWindowTitle property of the winamp process. Process winamp = Process.GetProcessesByName("winamp")[0]; if(winamp == null) return; IntPtr winampHwnd = winamp.MainWindowHandle; if( winampHwnd != IntPtr.Zero ) textBox1.Text = winamp.MainWindowTitle.Split('-')[1].Trim(); // just gets the title Link to comment Share on other sites More sharing options...
0 wa22guy Posted October 29, 2004 Author Share Posted October 29, 2004 Agh ok, thanks anyway. Link to comment Share on other sites More sharing options...
Question
wa22guy
Anyone know how to get the file location of the current playing song using C# for Winamp?
[Edit: Please edit my topic to add C# at the top]
Link to comment
Share on other sites
11 answers to this question
Recommended Posts