Search code examples
cunixflashnpapixlib

Display SWF file with NPAPI (on Xlib)


I have been struggling with NPAPI for "good" examples and "specific" documentations (on Unix). I have my libflashplayer.so, on which I can have access to certain information which is:

nm -D libflashplayer.so | more

00000000005cc4e0 T FlashPlayer_11_2_202_235_FlashPlayer
00000000005cc4a0 T Flash_DisableLocalSecurity
00000000005cc4c0 T Flash_EnforceLocalSecurity
00000000005ca870 T NP_GetMIMEDescription
00000000005ca850 T NP_GetValue
00000000005ca4d0 T NP_Initialize
00000000005ca4c0 T NP_Shutdown

I easily checked the MIMEDescription by doing this. Which return the flash MIME.

static char* (*mNP_GetMIMEDescription)(void);
//MAIN
lib = dlopen("./libflashplayer.so", RTLD_LAZY | RTLD_LOCAL);

*(void **) &mNP_GetMIMEDescription  = dlsym(lib, "NP_GetMIMEDescription");
fprintf(stderr, "NP_GetMIMEDescription=%p\n", mNP_GetMIMEDescription);
fprintf(stderr, "NP_GetMIMEDescription=%s\n", mNP_GetMIMEDescription());

//output
NP_GetMIMEDescription=0x7f2d2239f870
NP_GetMIMEDescription=application/x-shockwave-flash:swf:Shockwave Flash;application/futuresplash:spl:FutureSplash Player

Now, I'm really lost on how to render (or test, open a swf file) content on a Xlib Window. First, I do NP_INITIALIZE which I believe (from what I understand) provides Global Initialization (especially for NPNetscapeFuncs and NPPluginFuncs "instance"). Then the fun part begins, My guess (with what I read and understand, correct me if I am wrong) was to create an instance of my plugin (with NPP_New) and after, set my window (with NPP_SetWindow) to link my plugin instance and my window (from Xlib for example...)


Solution

  • This is exacly what I want to achieve.

    http://blog.henryfan.net/post/2012/01/09/gtk%E6%92%AD%E6%94%BEflash.aspx

    thanks to whoever wrote that down.