Old 20th September 2011, 19:36   #1
striker503
Junior Member
 
Join Date: Sep 2011
Posts: 27
Main Method?! like int main ()

hey,
i want to know if there's a method like the int main () method.
Or is there another possibility like a method which starts when the "play" button is triggered.

i'm really new to plugin-programming but i searched for it in the forums/google and wiki.
i'm also not sad if you only send me links where i can find the solution...

greets from germany <3

striker503
striker503 is offline   Reply With Quote
Old 25th September 2011, 14:24   #2
striker503
Junior Member
 
Join Date: Sep 2011
Posts: 27
/p is for push, thats what i do!

www.striker503.de
gaming | internet | news - blog
striker503 is offline   Reply With Quote
Old 29th September 2011, 00:58   #3
thinktink
Forum King
 
thinktink's Avatar
 
Join Date: May 2009
Location: On the streets of Kings County, CA.
Posts: 3,007
Send a message via Skype™ to thinktink
A Winamp plugin is not a standalone executable so therefore does not have an int main(...). It (generally) has a dll entry point function as Winamp plugins are DLLs.

A DLL entry point is a function in a DLL that is executed when a DLL is loaded or unloaded by a host application or thread. http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx. What the DLL entry point function is named greately depends on the compiler you've chosen to use to compile your plugin. Consult your compiler's documentation for how to compile a DLL and specify a DLL entry point.

A Winamp plugin also exports a function with a very specific function name with a specific set of parameters and return value that define where and how Winamp (the host application) calls functions and fills structures for the operation of your plugin. Depending on the type of plugin you are trying to create will determine not only what functions to export but also the name of your DLL file. For more information, consult the Winamp Plugin Developer SDK:
http://wiki.winamp.com/wiki/Plug-in_...ug-in_Overview
thinktink is offline   Reply With Quote
Old 29th September 2011, 16:08   #4
striker503
Junior Member
 
Join Date: Sep 2011
Posts: 27
Well, but i need the function to start when the "play" "pause" "stop" "next" button is triggered.
Well a message loop would be also enough like in the windowsprocc then i could set up a switch case loop and the prob is solved, does this exist?
i think the entry point isnt what i searched because i want to modify which track is played next, like the shuffle mode but i want to change some things

hope you understand what i want to say
-> else ask

www.striker503.de
gaming | internet | news - blog
striker503 is offline   Reply With Quote
Old 29th September 2011, 16:27   #5
DrO
 
Join Date: Sep 2003
Posts: 27,873
so basically what this example does -> http://nunzioweb.com/daz/gen_play_state/index.html

-daz
DrO is offline   Reply With Quote
Old 28th October 2011, 17:52   #6
striker503
Junior Member
 
Join Date: Sep 2011
Posts: 27
Quote:
#include "stdafx.h"
#include <windows.h>
#include "gen_xshuffle.h"
#include "wa_ipc.h"
#include <stdio.h>
#include <iostream>
#include <time.h>
#include <stdlib.h>
#include <fstream>
#include <strsafe.h>




using namespace std;

#pragma comment (lib, "winmm.lib")

// these are callback functions/events which will be called by Winamp
int init(void);
void config(void);
void quit(void);

//-----------------------------------------------------------------------------------------------------------------

// internal variables for the created embedded windows, subclassing, etc
WNDPROC lpWndProcOld = 0;

// used for the uninstall support so we know when not to save settings
// see winampUninstallPlugin(..) [implemented since 5.0]
BOOL no_uninstall = 1;

// just using these to track the paused and playing states
int was_paused = 0,
was_playing = 0;
DWORD play_duration = 0,
play_diff = 0;
LRESULT CALLBACK WinampWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam);
//-----------------------------------------------------------------------------------------------------------------


// this structure contains plugin information, version, name...
// GPPHDR_VER is the version of the winampGeneralPurposePlugin (GPP) structure
winampGeneralPurposePlugin plugin = {
GPPHDR_VER, // version of the plugin, defined in "gen_myplugin.h"
PLUGIN_NAME, // name/title of the plugin, defined in "gen_myplugin.h"
init, // function name which will be executed on init event
config, // function name which will be executed on config event
quit, // function name which will be executed on quit event
0, // handle to Winamp main window, loaded by winamp when this dll is loaded
0 // hinstance to this dll, loaded by winamp when this dll is loaded
};


// event functions follow

int init() {
//A basic messagebox that tells you the 'init' event has been triggered.
//If everything works you should see this message when you start Winamp once your plugin has been installed.
//You can change this later to do whatever you want (including nothing)
//-----------------------------------------------------------------------------------------------------------------

//Zufallsgenerator initialisieren
srand (timeGetTime ());

//-----------------------------------------------------------------------------------------------------------------
//Willkommensnachricht anzeigen?
int Welcomemsg = 1;
ifstream Input ("xShuffle.cfg");
Input.read ((char*) &Welcomemsg, sizeof (Welcomemsg));
Input.close ();

//Messagebox
if (Welcomemsg == 1)
{
MessageBox(plugin.hwndParent, L"xShuffle Plug-in", L"Open the settings!", MB_OK);
}

return 0;
}

void config() {
//A basic messagebox that tells you the 'config' event has been triggered.
//You can change this later to do whatever you want (including nothing)


wchar_t msg[1024];

int plsongs = SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_GETLISTLENGTH);
int rndnumber = (rand()%plsongs)+1;

wsprintf(msg,L"Nummer zwischen 1 und %i: %i",
plsongs,
rndnumber
);

//Config überschreiben
int Welcomemsg = 0;
ofstream Output ("xshufle.cfg");
Output.write ((char*) &Welcomemsg, sizeof (Welcomemsg));
Output.close ();


MessageBox(plugin.hwndParent,msg,L"xShuffle Config",MB_OK);
}

void ShowMessageOnStateChange(LPWSTR description){
wchar_t tmp[64];
if(was_playing) play_duration += (GetTickCount() - play_diff);
StringCchPrintf(tmp,64,L"%d ms",play_duration);
MessageBox(0,description,(play_diff?tmp:L""),0);
}

LRESULT CALLBACK WinampWndProc(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
{
if(umsg == WM_WA_IPC){
// this is sent after IPC_PLAYING_FILE on 5.3+ clients
if(lParam == IPC_PLAYING_FILEW){
DWORD diff = GetTickCount();
was_paused = 0;
ShowMessageOnStateChange((!was_playing ? L"Started Playback (unicode)" : L"Playback Changed (unicode)"));
play_duration = 0;
play_diff = diff;
was_playing = 1;
}

// this is sent in all 5.0+ clients
else if(lParam == IPC_PLAYING_FILE){
if(SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_GETVERSION) < 0x5030){
was_paused = 0;
play_duration = 0;
play_diff = GetTickCount();
MessageBox(0,(!was_playing ? L"Started Playback (ansi)" : L"Playback Changed (ansi)"),0,0);
was_playing = 1;
}
}

// this whole section tests the playback state to determine what is happening
else if(lParam == IPC_CB_MISC && wParam == IPC_CB_MISC_STATUS){
if(SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_ISPLAYING) == 1 &&
SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_GETOUTPUTTIME)){
if(was_paused){
was_paused = 0;
play_diff = GetTickCount();
MessageBox(0,L"Playback Unpaused",L"",0);
}
}
else if(SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_ISPLAYING) == 3){
was_paused = 1;
ShowMessageOnStateChange(L"Playback Paused");
}
else if(SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_ISPLAYING) == 0 && was_playing == 1){
was_playing = was_paused = 0;
ShowMessageOnStateChange(L"Playback Stopped");
}
else if(SendMessage(plugin.hwndParent,WM_WA_IPC,0,IPC_ISPLAYING) == 0 && was_playing == 0){
MessageBox(0,L"Not Playing - Track Advance Only",L"",0);
}
}

else if(lParam == IPC_GET_NEXT_PLITEM || lParam == IPC_GET_PREVIOUS_PLITEM){
// this would be where the next track to be played can be overriden
// but really api_queue should be used if gen_jumpex.dll is present
// (see gen_api_queue example for how to use the api_queue service)
ShowMessageOnStateChange(L"Playback Changing");
play_duration = 0;
}
}

// now make sure to call the original window proceedure otherwise things break!
return CallWindowProc(lpWndProcOld,hwnd,umsg,wParam,lParam);
}


void quit() {
//Quit
}


// This is an export function called by winamp which returns this plugin info.
// We wrap the code in 'extern "C"' to ensure the export isn't mangled if used in a CPP file.
extern "C" __declspec(dllexport) winampGeneralPurposePlugin * winampGetGeneralPurposePlugin() {
return &plugin;
}
This only triggers the init function. It ignores the others. Or do i need the WASABI methods too?

www.striker503.de
gaming | internet | news - blog
striker503 is offline   Reply With Quote
Old 28th October 2011, 17:56   #7
DrO
 
Join Date: Sep 2003
Posts: 27,873
that's because you've no subclassing of the Winamp window so the WinampWndProc will never be used. all i will suggest is actually looking at the example i linked to and noting how it does subclassing (as is mentioned in the code notes).

really from what you've said in earleir posts, using what i've said and then editing that will be better in the long run than trying to partial copy+paste stuff as you seem to have tried to do.

-daz
DrO is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > Winamp Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump