View Full Version : SendMessage for Previous
brian6p
8th March 2002, 21:43
Reader,
I am working on a little toy for myself and the group I am with. In theory it would all for us to put Winamp on a web server and then access a page that would perform functions against Winamp using the SendMessage call. My question is this for now: When I send Winamp the 'Previous' command, it does not always go to previous track. It just goes to the beginning of the song. Any ideas? Thanks in advance.
PS This is build on .Net C#
Gourou
8th March 2002, 22:09
I know the problem, I had the same one. an alternative would be to get the playlist position and move it back one spot and then hit play, that would guarantee that it plays, but that wont work with winamp on shuffle, so the second option is to have to send message(prev) commands stacked so it gets a sort of double click, that has usually worked, but if it's at the first 5 seconds or so of the song, then it goes back two tracks, so you'd have to determine exactly how far along it is, and send the appropriate number of sendmessage commands.
brian6p
8th March 2002, 22:11
Thanks alot!
Gourou
8th March 2002, 22:19
I need to say something on my last post, I just tested and I cant get winamp to simply restart the track, so doing a double back will take you back two tracks. I've heard that winamp has a truly internal playlist, I dont know how to access it, but it holds the recently played list and such, if anyone knows how to access this, maybe they can truly help you out...I just had an idea..:) Keep the song of the song before you hit previous, inside the program, if the song doesnt change after say 20 msecs, then hit back again, and make sure the song changed, now that should work :D
brian6p
9th March 2002, 00:04
Are you interested in this? I could send you the files.
Gourou
9th March 2002, 00:35
nah, I write in vb, I have a hard time following c or c++ code, it's just not in me :p
and I have my share of stuff, lots of it actually, go here and check out what I did with a web interface and a lil patience EFNX gateway (http://efnx.ath.cx)
click admin and put radioefnx as the password, or mebbe it's efnxradio, something like that, there are direct controls over the web, sort of like what you need, but mine dont give me any crap, so I cant really figure out your problem :confused: sorry
I also have queue lists and inside the admin console is a direct playlist, I just dont know c or anything else soze I cant convert it to help a lot of ppl :(
stevec88
13th March 2002, 23:27
I am just getting into this now, and could use all the help I can get. :) Do you have your compiled sample and/or source available for a lightweight like me?
Thanks.
Gourou
14th March 2002, 00:35
what language are you in?
stevec88
14th March 2002, 00:38
C# all the way, unless you want to talk old-school COM stuff, then it's Visual FoxPro 7 or Visual Basic 6.
Gourou
14th March 2002, 00:41
I'm old skool COM stuff :p
email that dude a couple posts up that had some gear or other, I dont write plugins, so I dont have some features, so I also dont need COM either
brian6p
14th March 2002, 00:43
What kind of C# code are you looking for. That is a pretty broad basis;)
stevec88
14th March 2002, 01:09
Well, I am working on creating a "WinAmp controller" as a C# Winform. Any WinForm code that does interop and can handle monitoring multiple filesystems would be great.
brian6p
14th March 2002, 02:17
This is pretty much what I have used to control winamp so far. It is far from final but it works. I think that I will be moving away from Winamp shortly because it does not all the functions that I want. At least I do not think so. Hope this helps:
public class MWAClass
{
private static string DEFAULT_LOCATION;
private string WinLoc = "c:\\program files\\winamp\\winamp.exe";
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
[DllImport("user32.dll", CharSet=CharSet.Auto)]
private static extern IntPtr FindWindow(string wClassName, string wName);
[DllImport("User32.Dll")]
public static extern void GetWindowText(int h, StringBuilder s, int nMaxCount);
System.IntPtr theWindow;
public MWAClass()
{
DEFAULT_LOCATION = WinLoc;
GetWindow(DEFAULT_LOCATION);
}
public MWAClass(string LocalWinampLocation)
{
DEFAULT_LOCATION = LocalWinampLocation;
GetWindow(DEFAULT_LOCATION);
}
private void GetWindow()
{
GetWindow(DEFAULT_LOCATION);
}
private void GetWindow(string WinampLocation)
{
theWindow = FindWindow("Winamp v1.x", null);
if((int)theWindow == 0)
{
ProcessStartInfo ProInfo = new ProcessStartInfo(WinampLocation);
ProInfo.UseShellExecute = false;
ProInfo.CreateNoWindow = false;
Process makeNew = new Process();
makeNew.StartInfo = ProInfo;
makeNew.Start();
while(!makeNew.Responding)
{}
theWindow = FindWindow("Winamp v1.x", null);
}
}
public void Close()
{
if((int)theWindow != 0)
{
SendMessage(theWindow, 273, 40001, 0);
}
else
{
GetWindow();
Close();
}
}
public void Play()
{
if((int)theWindow != 0)
{
SendMessage(theWindow, 273, 40045, 0);
}
else
{
GetWindow();
Play();
}
}
public void Pause()
{
if((int)theWindow != 0)
{
SendMessage(theWindow, 273, 40046, 0);
}
else
{
GetWindow();
Pause();
}
}
public void Stop()
{
if((int)theWindow != 0)
{
SendMessage(theWindow, 273, 40047, 0);
}
else
{
GetWindow();
Stop();
}
}
public void Next()
{
if((int)theWindow != 0)
{
SendMessage(theWindow, 273, 40048, 0);
}
else
{
GetWindow();
Next();
}
}
public void Previous()
{
if((int)theWindow != 0)
{
SendMessage(theWindow, 273, 40044, 0);
}
else
{
GetWindow();
Previous();
}
}
private string GetSongTitle()
{
StringBuilder SongTitle = new StringBuilder(2048);
GetWindowText((int)theWindow, SongTitle, 2048);
return SongTitle.Replace("- Winamp", "").ToString();
}
private int GetSongLength()
{
int theLength;
theLength = (int)SendMessage(theWindow, 1024, 1, 105);
return theLength;
}
public int SongLength
{
get
{
return GetSongLength();
}
}
public void Volume(int Amount)
{
if(Amount >= 0 && Amount <= 255)
{
SendMessage(theWindow, 1024, Amount, 122);
}
}
public string SongTitle
{
get
{
return GetSongTitle();
}
}
public int WindowValue
{
get
{
return (int)theWindow;
}
}
}
stevec88
14th March 2002, 11:08
Nice, thanks, I'll check this out today!
Gourou
14th March 2002, 11:13
that isnt very deep, no playlisting at all in there, just basic controls~ c# looks like a mix of vb and c++, a lot more c++ tho, or maybe I'm whack cuz most other languages I know also have that layout :p
brian6p
14th March 2002, 19:05
To Gourou:
You are right, it is not that different from C++ or VB besides syntax which is just about any language. But in truth it is the MS spin-off of Java. It even more closely resembles that syntax. Functionally MS is saying that all .Net languages are equal now. If you have a plug in to compile Python, Pearl, Cobol, etc. into the .Net CLR all the languages should have equal capability. It is just then which language you are more familiar with or like the most.
To stevec88:
How is the code working for you? Sorry there isn't more there but that is all I have had time to work with. My work has been taking up the time I would normally use to develop more personal utils. If you make any cool classes to control the playlist let me know;)
stevec88
14th March 2002, 22:18
I havenot yet had time to manipulate anything with the class. Probably in the next week I will have .1 of this going, and will post the redistributable here.
Thanks again!
vBulletin® v3.8.6, Copyright ©2000-2013, Jelsoft Enterprises Ltd.