简体   繁体   中英

Screensharing via Java Applet

I am looking for an addition for our "livestream and podcast" solution, which uses a camera to film speeches in our house.

It has been requested to view the slides of our speakers directly as a image in the webbrowser instead of the video stream. We don't want/can not install software on the speakers laptop, so I thought about a Java applet, which the speaker can just run via a webbrowser.

So what I need is technically this:

[speakers laptop] -> [Screencapture every N seconds via applet on a webpage] -> [Displaying the screen of the speaker on a different webpage for the external viewers]

I know there are Java applications which do record the screen, but save the file output locally. I need something that does the same, but sends the image to the server. On the server side I thought about a websocket.js accepting and displaying the image (other suggestions are welcome).

It would be great if somebody could help me out here. Btw, I never programmed in Java, so telling me which frameworks I need won't really help me.

Thanks!!

I was recently asked to evaluate possibilities for live screen-cast via applet. Most video APIs do not support codecs that have high enough compression (eg JMF). Some APIs can do advanced formats (JFFMPEG, Xuggle) but also use natives. While natives are normally no problem for an app. launched (free floating) using Java Web Start or a Plug-In 2 applet, the makers of Xuggle identify 'the order of loading natives' as a problem (eg won't work) for both JWS and applets.

It is a pity that more than a decade into its development, Java has no reasonable API for video capture/processing that can be deployed for a wide use (applet/JWS based - for the 'general public') GUI.

Perhaps you can find a solution using Flash.

Update 1

In fact, I do not need the screen to be recorded as a video.

In fact, you mentioned much of that in your initial question, but I focused on just a few keywords before drafting a reply. My bad. :P

OK.

  • Getting an image is relatively easy. An applet would need to be trusted in order to get a screenshot, but once trusted, it is just a few lines of code to get the image.
  • Encoding the image to JPEG of particular quality/compression setting (in memory) is also doable.
  • Sending the image to the server would depend on the size in bytes and connection speed, but one image with a high compression, every 10 seconds, should be doable. The server would need to implement functionality to accept the image.

As far as displaying the image on the client, it seems you already have some ideas based around JS. If you can make that work that would be optimal, since it can then be viewed in browsers with no Java.

I would still recommend you deploy the app. to the 'speaker' using Java Web Start , rather than embed an applet. A JWS app. will give you less deployment & maintenance troubles, and the JWS launch is ..nicer. Further, a free floating frame launched using JWS can minimize itself (or in later JREs, become transparent), during the action of taking a screen image - thereby capturing everything on the screen except itself.

Update 2

I actually found this code here.

That is ..horrible. Not the code, the site. When I visited it I got a message saying a pop-up had been suppressed (fair enough). Then there was the irritating 'vibrating dialog' hovering in the middle of the page (and following the scroll). You click the little x to see - another tab opened with yet another floating dialog, saying some other rubbish about how "You've won.." - with sound loud enough to drown out my high volume trance/dance playlist.

Then after closing that the hell out of my FF, I go back to the original page, close the damn 'dialog', scroll down & see.. a red background to the code (shudder). That is as far as I could manage. I closed the page with the code.

Try this code instead, for a single screen-shot.

Would it be possible to use this on the client side..

Yes.

.. and receive it with javascript on the server side?

Not really. Unless you mean an IIS based server running Microsoft's JScript. JavaScript is a client side technology.

For security reasons, servers need to protect themselves. EG From:

  • Someone creating a slavebot that uploads all the 1000s of docs on the slave machine's to the site - to make it crash.
  • People high-jacking your server for storing and serving bestiality porn (or worse).

Because of things like that (bad people have lots of imagination), while servers can easily accept uploads, they are generally not configured by default to allow them.

.. (I don't want Java on my server ;-)

It can be done using PHP, ASP, CGI etc. It does not need Java specifically, but it does need some active involvement from the server, if only to check the size of what is being uploaded and abort if it gets too large!

..Will take a look at the link you posted, but as I said, I can't program in Java, though I can understand some of it. Thanks!

It sounds like you'll need some help getting the server-side of it ready, as well. It is trivial for someone that knows how (not me), but a potential security nightmare for the inexperienced.

Update 3

where do I add the function to send the picture?

Sorry. I've not tried to implement that - you'd want to want to encode it to JPEG before sending, to reduce the size. See this code for how to provide an adjustable compression/quality where the user can see the effect.

There are various ways to get an image to a server. EG sockets, HTTP, FTP.. AFAIU it would depend on how the server is accepting it. I am unfamiliar with the specific term 'websocket' or the node.js script. Can you link to what you mean?

..the old code added to pastebin, so it's readable

Smart thinking. I notice it uses sockets, it was in the back of my mind that sockets would be best for this, since they have low overhead and short wait times.

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