i am trying to access my video devices for live streaming using the code

public class WebCam {
    private static Player player=null;
    //private static Processor processor=null;
    public static void main(String[] args){
            try {
                MediaLocator mediaLocator=new MediaLocator("vfw://0");
                player=Manager.createRealizedPlayer(mediaLocator);
                player.start();
                Component video=player.getVisualComponent();
                if(video!=null){

                   JFrame mediaTest = new JFrame("My WebCam");
                   mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                   mediaTest.add(video);
                   mediaTest.setSize(300, 300);
                   mediaTest.setVisible(true);
                }
            } catch (NoPlayerException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (CannotRealizeException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    }
    }

the code works fine but when i use

 Vector deviceList=CaptureDeviceManager.getDeviceList(new YuvFormat());
 CaptureDeviceInfo device=(CaptureDeviceInfo) deviceList.firstElement();

it throws an error what might be the possible error

it throws 'an error' ....
what error? what's in the stack trace?

my recommendation: even though JMF can be an asset, it's an unmaintained legacy library, which hasn't been updated for years (and there are also no plans to do so).

it might be a good idea to see whether or not you can find an alternative.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.