live streaming by Browsercomponent

34 views
Skip to first unread message

silver...@gmail.com

unread,
May 3, 2018, 11:04:38 AM5/3/18
to CodenameOne Discussions
Hello
it's been a week that I'm working on a live streaming solution using BrowserComponent's codeName one.
In fact I want to display the flow of a webcam by typing in a browser the URL of my webcam.
On a classic browser like firefox, or jxbrowser everything works normally, I can see the image of my camera.
But when I use the BrowserComponent component of CodeName one live streaming is not displayed.

Here is the piece of code that allows me to display a web page with browserComponent:

@SuppressWarnings("deprecation")
public void start() {
if(current != null){
current.show();
return;
}
//TableLayout tl = new TableLayout(3, 2);

try {

BrowserComponent browser = new BrowserComponent();
//browser.setURL("https://www.codenameone.com/");
//browser.setURL("https://orionassur.com/");
//browser.setURL("https://www.youtube.com");

TableLayout tl;
int spanButton = 2;
if(Display.getInstance().isTablet()) {
tl = new TableLayout(7, 2);
} else {
tl = new TableLayout(14, 1);
spanButton = 1;
}
// tl.setGrowHorizontally(true);
// Form hi = new Form("VSC-gBrowser",new BoxLayout(BoxLayout.Y_AXIS));
Form hi = new Form("VSC-Browser", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
// Form hi = new Form("VSC-Browser", new FlowLayout());
// Form hi = new Form("VSC-Browser", new GridLayout(2, 2));
hi.setLayout(tl);
TextField url = new TextField("", "URL", 10, TextArea.URL);


Button submit = new Button("Submit");
TableLayout.Constraint cn = tl.createConstraint();
cn.setHorizontalSpan(spanButton);
cn.setHorizontalAlign(Component.RIGHT);
hi.add(url).
add(cn, submit);

submit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
String urlValue = url.getText();
browser.setURL(urlValue);
// browser.execute("window.socket = io('"+urlValue+"')");

// Display.getInstance().execute(urlValue);



// .... do some operation on value ...
}
});


hi.add(BorderLayout.CENTER, browser);
hi.show();

} catch (Exception e) {

System.out.println("Division par zéro !");

}

}

once I start the execution here is what is displayed instead of the image of my webcam:


Is there possible to do liveStreaming with CodeName one by using BrowserComponent ? If yes I want to know how , if not is there any other solution to do it with codeName one ?

Thanks
Auto Generated Inline Image 1

Shai Almog

unread,
May 4, 2018, 12:07:43 AM5/4/18
to CodenameOne Discussions
Hi,
you are seeing mime-multipart. As I said here https://stackoverflow.com/questions/50158754/codename-one-how-to-do-live-streaming

I would suggest trying on the device as that can impact a lot. I'd also suggest reviewing the HTML of the webcam to see what they do there.

silver...@gmail.com

unread,
May 4, 2018, 8:06:53 AM5/4/18
to CodenameOne Discussions
I had another problem.
when I run an application like facebook, google etc. with BrowserComponent of my application, it works well in my simulator but when I deploy the APK that I downloaded from my CodeName one account on the device nothing is displayed.

Shai Almog

unread,
May 5, 2018, 12:22:49 AM5/5/18
to CodenameOne Discussions
You had lots of variants of the code commented out. Make sure the browser component is placed directly into the form in the center of a border layout.
Reply all
Reply to author
Forward
0 new messages