I want to create an application for P2P video transmission. In more details, I need the following:
User can switch on a web camera by clicking a button in an application.
Application starts to take images from the web camera and sends them to a certain location (given by a port and IP address).
Application starts to accept images send by another application and display them (images) in a window.
There is also one more thing. I would prefer to have everything in a browser. I know that everything can be done with Flash Player from Adobe (an example is http://chatroulette.com/).
But I would like to know if the same can be done with JavaScripts.
I am sure it the application can be written in Java. But can I use Java to have everything in a Browser.
I'm not sure that webcam access is available in any of the browsers natively yet so you might be out of luck for a pure js solution. I think there's meant to be something added to the spec soon though.
If you want to do it with flash (which is really the best way at present) take a look at red5 which you can run on the server to sit between the clients and deal with the video streaming.
Related
I'm in the process of developing a java web application using Spring MVC that will (among other things) be capable of recording video from a camera on an Android based tablet and ultimately transfer that video to the server (dbase or filesystem). I see there are a number of tools available that might allow me to do this one of two ways: (1) record that video locally in the browser and potentially upload the final product as a single file to the server (i.e. RecordRTC) or (2) establish a connection to the server that enables me to stream the video direct, leaving it to the server side to manage the actual recording (i.e. Kurento, Jitsi). However, there are a few gotchas in all of this that are making it difficult for me to determine (1) which way makes sense and (2) which way is actually proven to work:
must be capable of running in any browser on an Android based tablet (v 4.2+)
recorded video can be anywhere from 15 sec to 15 min in duration
users will be securely authenticated at login via Spring security; video streams/files need to be handled in that established session (which I don't think is possible with Kurento)
must be open source
I've been developing Java web applications for many years now, but the video capture and processing component is something new to me and I'm hoping those with experience in this arena could guide me in a direction that makes most logical sense.
NOTE: I am open to other ideas that might make more sense than what I've mentioned already. Given the direction of HTML5, I thought WebRTC would be the best route. But given some of the Android based browser limitations, I'm not sure.
Thanks!
Is it possible to have JavaScript which calls a Java file (or something of the sort), so we can connect to a Bluetooth device and send it commands from a web page?
If it is possible, what are some ideas behind it that I can use to get it working?
Sorry for my poor language, I am not really sure how to word it.
Java can be used to send files via Bluetooth, and there is a tutorial on it at http://today.java.net/pub/a/today/2004/07/27/bluetooth.html
You could run a Java applet from the web browser that would use Bluetooth, although it would probably come up with a warning asking if you want to give the applet access to the files on your computer. JavaScript, however, would not be necessary, since an applet can run directly on a webpage.
Is it possible to play a sound (.wav or .mp3) in a client's browser using a JSF web app?
I have tried using javax.sound.sampled.SourceDataLine and it worked on Windows, but when I deploy the .war on a Linux host I get this exception:
"javax.sound.sampled.LineUnavailableException: Audio Device Unavailable"
Java code executes on the server to generate web pages that are displayed in the client's browser. If you have JSF web app code using the javax.sound.sampled.SourceDataLine class, the sound will play on the server (if this is even possible...), not in the client's browser.
To play a sound at the client, you'll either have to reference an audio file in the web page as Pascal Thivent has posted, or you'll have to play the sound through a Flash/Silverlight/Java Applet plugin referenced in the page.
Is it possible to play a sound (.wav or .mp3) in a client's browser using a JSF web app?
I should have mentioned that, but this has nothing to do with JSF or any other server-side technology. If you want to play a sound on the client-side, generate the appropriate client-side code, i.e. HTML here.
HTML 5 has an <audio> tag but, until it gets mainstream, see Playing Sounds on a Web Site and How To Play Sound (which does a good job at summarizing the solutions) to learn more on the <embed> tag and the <object> tag.
I have tried using javax.sound.sampled.SourceDataLine and it worked on Windows, but when I deploy the .war on a Linux host I get this exception: "javax.sound.sampled.LineUnavailableException: Audio Device Unavailable"
This exception literally means that the machine where the code runs doesn't have an audio device. I can imagine that it is very reasonable that webservers doesn't have any audio device, this namely doesn't make any sense.
As others have pointed out, you need to play sound at the client machine. You can find here a lot of background information and examples.
Not via JSF but you can use primefaces for an app like that http://www.primefaces.org/showcase/ui/media.jsf
how can I let an SWF file to retrieve values immediately from Java application that does live calculations (Speed is a necessity).
question in other form : how can I
give my website browser immediate data
- that are bean calculated now - as fast as i
can ?
I'm going to assume the calculations are being done in a Java applet in the same browser where the flash is running.
You can call Javascript from within the applet using the following code. This code could then update the values in the flash animation.
import netscape.javascript.JSObject;
JSObject win = JSObject.getWindow(applet);
win.eval("window.alert('Hello from Java')");
If my assumption is incorrect, then where is the Java application running? On the client or server?
If it's on the server then you need Flash remoting. I believe there are a few different Flash remoting techniques. Try searching for java flash remoting. You can make it call the server every 2 seconds or so to get the latest data.
If it's running on the client I doubt you can connect to it from Flash because of security. A signed Java applet could connect anywhere it wants to. You could retrieve the data using it, then push it into Flash using the method described above. Would be a crazy hack though. Can you do the same thing with Flex? (I've never used Flex before).
If the speed is crucial, you would probably want to do it via some kind of socket connection. Usually signed applet or a WebStart Java application is able to open a listening socket. Flash application then would be able to connect to this socket and as a result you will have very fast bidirectional communication.
There are some caveats however.
You should bear in mind that user might get suspicious about weird socket activity on his machine, or it would be just blocked by a firewall - so you'll need to warn user.
In order to be able to connect from Flash to Java, you must dispatch crossdomain policy file from the listening socket (or any other below 1024 - see documentation for details; keywords: crossdomain, policy-file-request, loadPolicyFile). Also your Flash application might need to request such file manually from the Java application.
Couple of useful links on how to get certificate for your Java application: how to get free code signing certificate (Russian), similar but less detailed description in English.
However, if you are able (read: the speed is sufficient) to use Java Applet <-> JavaScript <-> Flash combination I'd advice to take advantage of it.
Im trying to create an app to control a pc remotely using java , i want to use red5 to let the admin control desktops using a flash movie
so i need to find java classes to :
capture desktop as live video
-control mouse and keyboard
TightVNC has a Java viewer so you can easily manage your server through VNC protocol and use a Java client (usable as an applet too).
There are tools, though not in Java, such as vncrec to record VNC sessions. I don't know if this is exactly what you are looking for since to distribute video a better choice would be to set up a streaming server.
I don't believe Java libraries exist that will give you what you want. Capturing the screen and controlling the mouse/keyboard require hooking into the OS in ways that Java doesn't do. You'd need to write a native DLL that uses JNI and exposes the functionality you need, and then load that in java. Then you'd have to convert the image data you get into a format that Flash can understand.
Creating a live video stream probably wouldn't be the most effective. Generally streamed video is fairly lossy (which generally isn't that great when screen sharing), and is at smaller resolutions than you'd probably be dealing with. I'm not sure you could create a video that would both stream fast enough and have high enough image quality to be usable.
You're probably better off using a pre-existing product for this (like TightVNC, as Fernando suggested). Unfortunately, that would require a java applet (or native application) to view, not Flash.
(Full Disclosure: I've written screen sharing applications that use Java on both ends, both the server and the viewer, and we've looked at trying to make a Flash viewer a number of times.)
Just use VNC. You can call the VNC server executable from Java. On the client you can use the Java VNC Viewer. I'm sure there's source code somewhere if you really need to make changes to it. You could use AppletWindow from BlueJ to launch the VNC viewer applet inside a JFrame in any Java app.