[MPlayer-dev-eng] Embedding mplayer in Java swing application

rexian maillist at roomity.com
Wed Oct 5 17:55:15 CEST 2005


I got some very good replies to my earlier mail on possibility of embedding mplayer so writing again as I am having a few issues while trying to implement the idea.

Has anybody been successful in embedding the mplayer window in a Java swing application on Linux ? I saw the SWT sample code in the mplayer-cygwin list that does something very similar on windows.

I am trying it on Linux and with swing, instead of SWT. Getting the hwnd is a little different from SWT but should work nevertheless. I am trying to get the handle to x11 with the following code but when the java counterpart "getHWND()" is called, it crashes the JVM.

It'll be a great help if anyone can suggest something.

JNIEXPORT jint JNICALL Java_VideoCanvas_getHWND
(JNIEnv* env, jobject canvas)
{
    JAWT awt;
    JAWT_DrawingSurface* ds;
    JAWT_DrawingSurfaceInfo* dsi;
    JAWT_X11DrawingSurfaceInfo* dsi_x11;
    jboolean result;
    jint lock;
    Drawable handle_x11 = 0;
    void *jawt_handle;
    typedef jboolean (*JAWT_GetAWT)(JNIEnv*, JAWT*);

        ds = awt.GetDrawingSurface(env, canvas);
        if (ds != NULL)
        {

            lock = ds->Lock(ds);
            if ((lock & JAWT_LOCK_ERROR) == 0)
            {
                dsi = ds->GetDrawingSurfaceInfo(ds);
                dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
                handle_x11 = (Drawable) dsi_x11->drawable;
                ds->FreeDrawingSurfaceInfo(dsi);
                ds->Unlock(ds);
            }
        }
        awt.FreeDrawingSurface(ds);

    return (jint)handle_x11;
}

Thanks,
Rex



-----------------------------------------------------------------------------
<a href="http://MPlayer_Developer_List_(English).roomity.com">roomity.com</a>
roomity.com is broadband internet. ~~1128527715196~~
-----------------------------------------------------------------------------



More information about the MPlayer-dev-eng mailing list