简体   繁体   中英

How does a browser interact with a Flash Player or a Java Applet?

I've been trying to understand how flash animations or a Java Applet work within a browser.

I can think of a couple of ways -

  1. The Flash Player/Java Applet are machine code that's dynamically linked it, and given some parameters about the area of the screen that belongs to them; after that, they run within the same process space.

  2. The browser exposes an API that the player/applet use to talk to it and they live in a separate process. (Presumably they talk via sockets?) The API could correspond to openGL/X11/some custom calls.

These possibilities still don't explain things like how a button click can make the player full-screen, how it can play music, how it can inspect the DOM, etc. For that matter, is the video displayed by decoding to a sequence of images, and rendering them one at a time, or is there a more efficient way, eg, of pushing the deltas in the image?

The Wikipedia page on Java Applets ( 1 ) talks about how the applet is run in a sandbox (presumably a separate process), but it doesn't say how the browser and the applet communicate.

Perhaps the answer depends on the underlying platform?

Any pointers to systematic discussion of this topic would be appreciated (as would a reference to the APIs).

(My interest in this stems from an insatiable curiosity.)

I'm pretty sure plugins like Java applets and Flash run via NPAPI in most browsers. I looked into this matter myself some time ago and NPAPI was the answer I found.

In the case of browser and Java applets, the applets are typically run within the Java plugin, which runs as a separate process (you can see it eg in the task administrator in Windows).

The plugin creates an object for each applet in the DOM, and you can thus interact with the applet from Javascript. Anyway, calls to the applet that take a while to return do have the effect to freeze the browser, therefore I'd say the communication with the plugin runs in the same thread as the main refresh loop. This seems at least to be the case with Firefox.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM