Winamp plugin.. wee adds winamp_* commands, winamp_restart is a bit buggy, ill fix that later

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@1584 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Lance 2005-11-26 02:54:07 +00:00
parent 9964d73a8d
commit 8536976d16
4 changed files with 1727 additions and 0 deletions

553
plugins/winamp/winamp.c Normal file
View File

@ -0,0 +1,553 @@
//mp3 menu and track selector.
//was origonally an mp3 track selector, now handles lots of media specific stuff - like q3 films!
//should rename to m_media.c
/*«11:56:05 am» «@Spikester» EBUILTIN(void, Menu_Control, (int mnum));
«11:56:05 am» «@Spikester» #define MENU_CLEAR 0
«11:56:05 am» «@Spikester» #define MENU_GRAB 1
«11:56:05 am» «@Spikester» EBUILTIN(int, Key_GetKeyCode, (char *keyname));
«11:56:13 am» «@Spikester» that's how you do menus. :)*/
#define BUILD 1
#include <stdlib.h> // needed for itoi
#include <stdio.h> // needed for itoi?
#include <windows.h>
#include "../plugin.h"
#include "winamp.h"
HWND hwnd_winamp;
//int media_playing=true;//try to continue from the standard playlist
//cvar_t winamp_dir = {"winamp_dir", "c:/program files/winamp5/"};
//cvar_t winamp_exe = {"winamp_exe", "winamp.exe"};
//cvar_t media_shuffle = {"media_shuffle", "1"};
//cvar_t media_repeat = {"media_repeat", "1"};
qboolean WinAmp_GetHandle (void)
{
if ((hwnd_winamp = FindWindow("Winamp", NULL)))
return true;
if ((hwnd_winamp = FindWindow("Winamp v1.x", NULL)))
return true;
if ((hwnd_winamp = FindWindow("winamp", NULL)))
return true;
return false;
}
// Start Moodles Attempt at Winamp Commands
// Note strange bug, load up FTE normally. And type winamp_version, for me the output is 0, but if I do winamp_version a second time it says 24604 (which is hex for 5010, my version of winamp is 5.10)
void Winamp_Play_f(void)
{
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
//SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_BUTTON2, 0); <- is below fails, uncomment this.
SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_STARTPLAY);
Con_Printf("Attempting to start playback\n");
}
void Winamp_Version_f(void)
{
int version;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
version = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETVERSION);
//itoa (version, temp, 16); // should convert it to hex
Con_Printf("Winamp Version: %d\n",version);
}
void Winamp_TimeLeft_f(void)
{
int tracklength;
int trackposition;
int timeleft;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
tracklength = SendMessage(hwnd_winamp,WM_WA_IPC,1,IPC_GETOUTPUTTIME);
trackposition = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETOUTPUTTIME);
timeleft = tracklength-(trackposition/1000);
Con_Printf("Time Left: %d seconds\n",timeleft); // convert it to h:m:s later
}
void Winamp_JumpTo_f(void) // input is a percentage
{
int tracklength;
float inputpercent;
double trackpercent;
char input[20];
int res;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
tracklength = SendMessage(hwnd_winamp,WM_WA_IPC,1,IPC_GETOUTPUTTIME);
Cmd_Argv(1,input,sizeof(input));
inputpercent = atoi(input);
if (inputpercent > 100)
{
Con_Printf("ERROR: Choose a percent between 0 and 100\n");
return;
}
inputpercent = inputpercent/100;
trackpercent = (tracklength*1000)*inputpercent;
res = SendMessage(hwnd_winamp,WM_WA_IPC,trackpercent,IPC_JUMPTOTIME);
if (res == 0)
{
Con_Printf("Successfully jumped to %s percent\n",input,trackpercent);
return;
}
else if (res == -1)
{
Con_Printf("There are no songs playing\n");
return;
}
else if (res == 1)
{
Con_Printf("End of file\n");
}
Con_Printf("Oh oh spagettioes you shouldn't see this");
}
void Winamp_GoToPlayListPosition_f(void) // the playlist selecter doesn't actually work
{
//int length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH); //set a max
char input[20];
int inputnumber;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
Cmd_Argv(1,input,sizeof(input));
inputnumber = atoi(input);
SendMessage(hwnd_winamp,WM_WA_IPC,inputnumber,IPC_SETPLAYLISTPOS);
SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_STARTPLAY); // the above only selects it, doesn't actually play it.
Con_Printf("Attemped to set playlist position %s\n",input);
}
void Winamp_Volume_f(void) // I think this only works when the client did the winamp_play
{
char input[20];
int inputnumber;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
Cmd_Argv(1,input,sizeof(input));
inputnumber = atoi(input);
if ((input == "") || (inputnumber > 255))
{
Con_Printf("Choose a number between 0 and 255\n");
return;
}
SendMessage(hwnd_winamp,WM_WA_IPC,inputnumber,IPC_SETVOLUME);
Con_Printf("Winamp volume set to: %s\n",input);
}
void Winamp_ChannelPanning_f(void) // doesn't seem to work for me
{
char input[20];
int inputnumber;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
Cmd_Argv(1,input,sizeof(input));
inputnumber = atoi(input);
if ((input == "") || (inputnumber > 255))
{
Con_Printf("Choose a number between 0 (left) and 255 (right). Center is about 127\n");
return;
}
SendMessage(hwnd_winamp,WM_WA_IPC,inputnumber,IPC_SETPANNING);
Con_Printf("Winamp channel panning set to: %s\n",input);
}
void Winamp_PlayListLength_f(void) // has a habit of returning 0 when you dont use winamp_play to start off playing
{
int length;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH);
Con_Printf("Winamp playlist length: %d\n",length);
}
void Winamp_PlayListPosition_f(void) // has a habit of return 0 of 0
{
int pos;
int length;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
pos = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTPOS);
length = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETLISTLENGTH);
Con_Printf("Winamp currently on position '%d' of '%d'\n",pos,length);
}
void Winamp_SongInfo_f(void)
{
char title[255];
int res;
int samplerate;
int bitrate;
int channels;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
res = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_ISPLAYING);
samplerate = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GETINFO);
bitrate = SendMessage(hwnd_winamp,WM_WA_IPC,1,IPC_GETINFO);
channels = SendMessage(hwnd_winamp,WM_WA_IPC,2,IPC_GETINFO);
GetWindowText(hwnd_winamp, title, sizeof(title));
if (res == 0)
{
Con_Printf("WinAmp is off\n");
return;
}
else if (res == 1)
{
Con_Printf("Currently playing: %s\nSamplerate: %dkHz\nBitrate: %dkbps \nChannels: %d\n",title,samplerate,bitrate,channels);
return;
}
else if (res == 3)
{
Con_Printf("Winamp is paused\n");
return;
}
}
void Winamp_Restart_f(void)
{
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_RESTARTWINAMP);
Con_Printf("Attempting to restart winamp\n");
}
void Winamp_Shuffle_f(void) //it works, thats all i can say lol
{
char input[20];
int inputnumber;
int inputnumber2;
int get;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
get = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_SHUFFLE);
Cmd_Argv(1,input,sizeof(input));
inputnumber2 = atoi(input);
//inputnumber = Cmd_Argc();
inputnumber = 1; // fix later
if (inputnumber2 == 1)
{
SendMessage(hwnd_winamp,WM_WA_IPC,1,IPC_SET_SHUFFLE);
Con_Printf("Winamp shuffle turned on\n");
return;
}
else if ((inputnumber2 == 0) && (inputnumber == 2))
{
SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_SET_SHUFFLE);
Con_Printf("Winamp shuffle turned off\n");
return;
}
else if (get == 1)
{
Con_Printf("Winamp shuffle is currently on\n");
}
else if (get == 0)
{
Con_Printf("Winamp shuffle is currently off\n");
}
Con_Printf("Enter 1 to to turn Winamp shuffle on, 0 to turn it off\n");
return;
}
void Winamp_Repeat_f(void) // it works, thats all i can say lol
{
char input[20];
int inputnumber;
int inputnumber2;
int get;
if (!WinAmp_GetHandle())
{
Con_Printf("Winamp not loaded\n");
return;
}
get = SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_GET_REPEAT);
Cmd_Argv(1,input,sizeof(input));
inputnumber2 = atoi(input);
//inputnumber = Cmd_Argc();
inputnumber = 2; // fix later
if (inputnumber2 == 1)
{
SendMessage(hwnd_winamp,WM_WA_IPC,1,IPC_SET_REPEAT);
Con_Printf("Winamp repeat turned on\n");
return;
}
else if ((inputnumber2 == 0) && (inputnumber == 2))
{
SendMessage(hwnd_winamp,WM_WA_IPC,0,IPC_SET_REPEAT);
Con_Printf("Winamp repeat turned off\n");
return;
}
else if (get == 1)
{
Con_Printf("Winamp repeat is currently on\n");
}
else if (get == 0)
{
Con_Printf("Winamp repeat is currently off\n");
}
Con_Printf("Enter 1 to to turn Winamp repeat on, 0 to turn it off\n");
return;
}
void Winamp_VolumeUp_f(void)
{
SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_VOLUMEUP, 0);
Con_Printf("Winamp volume incremented\n");
}
void Winamp_VolumeDown_f(void)
{
SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_VOLUMEDOWN, 0);
Con_Printf("Winamp volume decremented\n");
}
void Winamp_FastForward5Seconds_f(void)
{
SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_FFWD5S, 0);
Con_Printf("Winamp fast forwarded 5 seconds\n");
}
void Winamp_Rewind5Seconds_f(void)
{
SendMessage(hwnd_winamp, WM_COMMAND, WINAMP_REW5S, 0);
Con_Printf("Winamp rewinded 5 seconds\n");
}
// End Moodles Attempt at Winamp Commands
int Plug_ExecuteCommand(int *args)
{
char cmd[256];
Cmd_Argv(0, cmd, sizeof(cmd));
if (!strcmp("winamp_play", cmd))
{
Winamp_Play_f();
return 1;
}
else if (!strcmp("winamp_version", cmd))
{
Winamp_Version_f();
return 1;
}
else if (!strcmp("winamp_timeleft", cmd))
{
Winamp_TimeLeft_f();
return 1;
}
else if (!strcmp("winamp_jumpto", cmd))
{
Winamp_JumpTo_f();
return 1;
}
else if (!strcmp("winamp_gotoplaylistposition", cmd))
{
Winamp_GoToPlayListPosition_f();
return 1;
}
else if (!strcmp("winamp_volume", cmd))
{
Winamp_Volume_f();
return 1;
}
else if (!strcmp("winamp_channelpanning", cmd))
{
Winamp_ChannelPanning_f();
return 1;
}
else if (!strcmp("winamp_playlistlength", cmd))
{
Winamp_PlayListLength_f();
return 1;
}
else if (!strcmp("winamp_playlistposition", cmd))
{
Winamp_PlayListPosition_f();
return 1;
}
else if (!strcmp("winamp_songinfo", cmd))
{
Winamp_SongInfo_f();
return 1;
}
else if (!strcmp("winamp_restart", cmd))
{
Winamp_Restart_f();
return 1;
}
else if (!strcmp("winamp_shuffle", cmd))
{
Winamp_Shuffle_f();
return 1;
}
else if (!strcmp("winamp_repeat", cmd))
{
Winamp_Repeat_f();
return 1;
}
else if (!strcmp("winamp_volumeup", cmd))
{
Winamp_VolumeUp_f();
return 1;
}
else if (!strcmp("winamp_volumedown", cmd))
{
Winamp_VolumeDown_f();
return 1;
}
else if (!strcmp("winamp_fastforward5seconds", cmd))
{
Winamp_FastForward5Seconds_f();
return 1;
}
else if (!strcmp("winamp_rewind5seconds", cmd))
{
Winamp_Rewind5Seconds_f();
return 1;
}
return 0;
}
void Winamp_InitCommands(void)
{
Cmd_AddCommand("winamp_play");
Cmd_AddCommand("winamp_version", Winamp_Version_f);
Cmd_AddCommand("winamp_timeleft", Winamp_TimeLeft_f);
Cmd_AddCommand("winamp_jumpto", Winamp_JumpTo_f);
Cmd_AddCommand("winamp_gotoplaylistposition", Winamp_GoToPlayListPosition_f);
Cmd_AddCommand("winamp_volume", Winamp_Volume_f);
Cmd_AddCommand("winamp_channelpanning", Winamp_ChannelPanning_f);
Cmd_AddCommand("winamp_playlistlength", Winamp_PlayListLength_f);
Cmd_AddCommand("winamp_playlistposition", Winamp_PlayListPosition_f);
Cmd_AddCommand("winamp_songinfo", Winamp_SongInfo_f);
Cmd_AddCommand("winamp_restart", Winamp_Restart_f);
Cmd_AddCommand("winamp_shuffle", Winamp_Shuffle_f);
Cmd_AddCommand("winamp_repeat", Winamp_Repeat_f);
Cmd_AddCommand("winamp_volumeup", Winamp_VolumeUp_f);
Cmd_AddCommand("winamp_volumedown", Winamp_VolumeDown_f);
Cmd_AddCommand("winamp_fastforward5seconds", Winamp_FastForward5Seconds_f);
Cmd_AddCommand("winamp_rewind5seconds", Winamp_Rewind5Seconds_f);
}
int Plug_Init(int *args)
{
if (Plug_Export("ExecuteCommand", Plug_ExecuteCommand))
{
Con_Printf("Winamp Plugin Build 1 by Moodles Loaded\n");
}
else
{
Con_Printf("Winamp Plugin failed\n");
}
Winamp_InitCommands();
return 1;
}

123
plugins/winamp/winamp.dsp Normal file
View File

@ -0,0 +1,123 @@
# Microsoft Developer Studio Project File - Name="winamp" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=winamp - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "winamp.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "winamp.mak" CFG="winamp - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "winamp - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "winamp - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "winamp - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINAMP_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINAMP_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "NDEBUG"
# ADD RSC /l 0x809 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib wsock32.lib /nologo /dll /machine:I386 /out:"Release/winampx86.dll"
!ELSEIF "$(CFG)" == "winamp - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINAMP_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "WINAMP_EXPORTS" /FR /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib wsock32.lib /nologo /dll /debug /machine:I386 /out:"c:\games\quake\id1\plugins\winampx86.dll" /pdbtype:sept
!ENDIF
# Begin Target
# Name "winamp - Win32 Release"
# Name "winamp - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=.\winamp.c
# End Source File
# Begin Source File
SOURCE=..\plugin.c
# End Source File
# Begin Source File
SOURCE=..\qvm_api.c
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\plugin.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File
SOURCE=..\plugin.def
# End Source File
# End Target
# End Project

29
plugins/winamp/winamp.dsw Normal file
View File

@ -0,0 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "winamp"=.\winamp.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

1022
plugins/winamp/winamp.h Normal file

File diff suppressed because it is too large Load Diff