Click here to Skip to main content
15,943,089 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I had this java class which the code is a Jframe showing out webcam video when executing it in Java Application. But I want to execute this class in Android application and view the live video through the Android app.


import javax.swing.JFrame;
import java.awt.*; 
import java.awt.event.*; 
import java.util.Vector;

public class Camfeed {
String Video_Device = "vfw:Microsoft WDM Image Capture:0";
JFrame frame = new JFrame(" Hello JMF Player"); 
static Player player = null; 

	public Camfeed() throws NoPlayerException, CannotRealizeException, IOException
		// Get the device list and store it in a vector

		Vector		CaptureDeviceInfo device = (CaptureDeviceInfo) deviceList.firstElement();

		MediaLocator ml = device.getLocator();	
                // Create the player 	
		player = Manager.createRealizedPlayer(ml);		
                //Get the visual component
		Component videoScreen = player.getVisualComponent();
		// Put the visual component inside a frame 
		frame.getContentPane().add( videoScreen, BorderLayout.CENTER); 
		frame.addWindowListener( new WindowAdapter() { 
			public void windowClosing(WindowEvent we) { 
				 Camfeed.stop();    System.exit(0); 

		frame.setSize( new Dimension(400,400) ); 

	public static void stop(){ 


	public static void main(String as[]) throws NoPlayerException, CannotRealizeException, IOException
		Camfeed c= new Camfeed();

Updated 29-Dec-13 1:28am
Nelek 29-Dec-13 18:17pm    
Perfect, go ahead.

Since you didn't ask any question, it is difficult to give you a better answer.
NooobieCoder 29-Dec-13 21:09pm    
Hi, i want to show it through android application. My project has stopped working whenever I open it in android application. Isit because the JFrame does not support Android?
Xiao Ling 29-Dec-13 22:11pm    
It's impossible. Although the programming language is same, the underlying framework is totally different. You have to implement it again based on Android framework.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900