I’m using the Webkit plugin facility to implement the <video> tag in an embedded environment. (for those interested, I was inspired by this)
I successfully connected my plugin’s methods and properties to map the ones that the HTML5 tag should expose in the MediaPlayerPrivate class of Webkit (I know how to query properties and to invoke simple methods), but I’m now wondering how my plugin can pass back data to the MediaPlayer interface.
My plugin implements the addEventListener() interface in JavaScript, so I figured I could use it to register the MediaPlayer client as an EventListener, but I can’t figure how.
What I would like to do is like this:
Plugin WebKit
+--------------+ +-----------------------------+
| | | |
| <-------------|-+addEventListener(callback) |
| | | |
|+----------+ | | |
|| | | | |
|| onEvent | | | |
|+----------+--------------> callback( EventData ) |
| | | |
+--------------+ +-----------------------------+
What I don’t know, is how I can call the method addEventListener of my plugin and pass it a JSObject that refers to a static callback in my C++.
Do you have any idea on how to do that?
(ASCII drawings thanks to Asciiflow)
For those interested, the solution is as such:
With this code, whenever my plugin object broadcasts an event, I see the code landing in my
callbackstatic function.Now I just have to find a way to pass the private data I need so that I can modify runtime values from this static function.