Announcement

Collapse
No announcement yet.

Winamp and Java (JNI) problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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
    WACUP Project <‖> "Winamp Ramblings" - Indie Winamp Dev Blog

    Comment


    • #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; 29 July 2010, 23:14.

      Comment


      • #4
        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
        WACUP Project <‖> "Winamp Ramblings" - Indie Winamp Dev Blog

        Comment


        • #5
          that's something to look in to.

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

          ~Theepot

          Comment

          Working...
          X
          😀
          🥰
          🤢
          😎
          😡
          👍
          👎