0

I am making a plugin for safari on mac. I am stuck at how to create a window over browser's window upon which a video can be displayed.

Earlier, we were using Cocoa Event model under which window pointer received in NPWindow in NPP_SetWindow function is null. Then we switched to Carbon Event model and we got pointer to NP_CGContext via window pointer present in NPWindow struct, using which we got pointer to WindowRef and got a pointer to NSWindow as following:

NP_CGContext* npContext = (NP_CGContext*)npWindow->window;
WindowRef window = npContext->window;
NSWindow* browserWindow = [[[NSWindow alloc] initWithWindowRef:window] autorelease];

Our streaming engine accepts the pointer to NSWindow. We don't know how to create a window in our browser space.

So any help regarding the window creation would be appreciated.

Pawan
  • 1,537
  • 1
  • 15
  • 19
  • I cannot advise you strongly enough that the premise of your series of questions--wanting to make an NPAPI plugin to stream video--is deeply and fundamentally flawed. Chrome has removed NPAPI plugin support, Mozilla has announced they will remove support by the end of 2016, and while Apple hasn't announced any plans they are aren't generally known for extended support of deprecated technologies. You have picked the technology that is least likely to continue to exist for this project. I strongly recommend either using web standards for video, or making an app rather than a plugin. – smorgan Oct 31 '15 at 15:59

1 Answers1

1

Our streaming engine accepts the pointer to NSWindow. We don't know how to create a window in our browser space.

You should not do this, as explained in previous answers.

A streaming engine that requires an NSWindow pointer is very poorly suited to making an NPAPI plugin. You should if at all possible look for something that takes or vends a CALayer, or failing that, which can draw frames into CGContextRef (but this will be much slower in out-of-process plugins).

If you absolutely must use an NSWindow, then you'll need to make a new one in your plugin process that is completely unrelated to the browser's window, and display it somewhere on screen. The user experience will be relatively poor, because it won't move with the window, can end up behind the browser window, etc. This is explicitly discouraged by browser vendors. But if you have no choice but to use an NSWindow, then this is your only option with modern browsers.

Community
  • 1
  • 1
smorgan
  • 20,228
  • 3
  • 47
  • 55