The question is published on by Tutorial Guruji team.
In my application there is a video button. Here’s the code.
@Override protected void onGUI1_Button1Action (Component c, ActionEvent event){ try { String value = Capture.captureVideo(); if (value != null) { final Form previous = Display.getInstance().getCurrent(); Form preview = new Form("Preview"); preview.setLayout(new BorderLayout()); MediaPlayer pl = new MediaPlayer(); if (!value.startsWith("file:/")) { value = "file:/" + value; } pl.setDataSource(value); preview.addComponent(BorderLayout.CENTER, pl); preview.setBackCommand(new Command("Back") { public void actionPerformed(ActionEvent evt) { previous.showBack(); } }); preview.show(); } } catch (Exception ex) { Log.e(ex); Dialog.show("Error", "" + ex, "OK", null); } }
I picked up this code from github. I don’t want to broadcast the video on full screen. I need a video from camera was built into some container. That container must cover only part of the screen. I have built a GUI and put a container(Media Player) into some part of screen. How to change the code for this purpose?
Answer
You can place a camera view finder right into your app with a new cn1lib: https://github.com/codenameone/CameraKitCodenameOne
Overlaying native widgets has been possible for a year or so by now.
Original answer which was correct when it was written is below:
Embedding camera or overlaying component on the preview screen is not yet available in codename one.
This could be done using native interface with peer component. Have a look at how Native map was implemented here