Old 29th July 2010, 12:22   #1
theepot
Junior Member
 
Join Date: Jul 2010
Posts: 3
Winamp and Java (JNI) problem

Hi,
I'm trying to write a Winamp plugin in Java with use of JNI.

this is my JavaNative class:
code:

public class JavaNative
{
static
{
System.load("D:\\Applications\\Winamp\\Plugins\\gen_wmpTest.dll");
}

public static native void playPause();
}



this is the (important) code in gen_wmpTest:
code:

void config()
{
// invoked when plugin is configured
SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
}

JNIEXPORT void JNICALL Java_JavaNative_playPause(JNIEnv *env, jclass cls)
{
printf("jni call\n");
SendMessage(plugin.hwndParent, WM_WA_IPC, 0, IPC_STARTPLAY);
}



When I configure my plugin in Winamp it will start playing (as it should).
But when I make a call to playPause() in Java it doesn't
i DO get the message "jni call" in my command prompt.

Anyone has a clue on what I am doing wrong?

Thanks,
Theepot
theepot is offline   Reply With Quote
Old 29th July 2010, 14:36   #2
DrO
 
Join Date: Sep 2003
Posts: 27,873
if you're getting the printf(..) on playPause(..) then either the value of plugin.hwndParent has changed / become invalid or maybe Winamp is already playing and it's possible sending that message again will have no effect (i can't remember what the expected behaviour is and am not in a position to try out actual code).

you could try using SendMessage(plugin.hwndParent, WM_COMMAND, MAKEWPARAM(WINAMP_BUTTON3, 0), 0); to toggle the paused state (as i'll assume is what you're trying to achieve with that function.

-daz
DrO is offline   Reply With Quote
Old 29th July 2010, 23:22   #3
theepot
Junior Member
 
Join Date: Jul 2010
Posts: 3
when winamp is playing it will just jump to the start of the song
plugin.hwndParent might have changed but I'm not sure how that part works (didn't find a goog tut on it either).

I'll try your suggestion and post the results

EDIT:
i tried your line of code and it worked in the config() function but not in playPause().
think your right about the value of plugin.hwndParent having changed, got no clue on how to fix that though.

~Theepot

Last edited by theepot; 30th July 2010 at 00:14.
theepot is offline   Reply With Quote
Old 30th July 2010, 14:46   #4
DrO
 
Join Date: Sep 2003
Posts: 27,873
the only thing i can think off is to do a test on plugin.hwndParent in playPause(..) and check that it is a valid HWND (can use IsWindow(..) ) and try to work it out from there as i've no idea how JNI works with plug-ins and if it keeps loading the plug-in dll again causing the plugin.hwndParent member to become invalid or never get filled in.

-daz
DrO is offline   Reply With Quote
Old 31st July 2010, 10:37   #5
theepot
Junior Member
 
Join Date: Jul 2010
Posts: 3
that's something to look in to.

well thanks for the help I'll try to figure it out!

~Theepot
theepot 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