Android Question How to Pass Command from Javascript Function to Webview in B4A

omo

Active Member
Licensed User
Hello, honorable members, referring to this link earlier raized: https://www.b4x.com/android/forum/t...ont-and-back-camera-on-webrtc-webview.119962/

I have carried out more intense research by dwelling only on javascript based on @ Erel's suggestion. I have used webviewextras and webviewextras2 (not together) just to make sure i execute javascript function that can pass command to webrtc to change phone camera from front to back and verse-versa. I have tried several examples on this forum, but many focuses were just on (1) loading javascript/html resource into webview i.e webview1.loadURL(....) (2) Passing data (values) from javascript to webview i.e WebViewExtras1.ExecuteJavascript(WebView1, "',true)};"). I only succeeded in loading asset javascript/html file into webview, which did not change the camera,but affected current display by loading itself into webview. Now, my question is: Can i send command from javascript function to webview in b4a without loading into webview or send data from javascript? However, if loading URl or passing data will solve my problem, i don't care so far it works. Please, help me
 

drgottjr

Well-Known Member
Licensed User
i can set the back-facing camera in javascript. it is as i told you. flipping back and forth requires other steps which you will have to learn. (i only have a vague understanding of the protocol). assuming you simply want to find some already created webrtc demo, you will need to find one that exposes these necessary steps. injecting the javascript to use front-facing or back-facing camera is trivial once you learn what you need to learn about webrtc.
 

Attachments

  • back.png
    back.png
    108 KB · Views: 52
Upvote 0

omo

Active Member
Licensed User
i can set the back-facing camera in javascript. it is as i told you. flipping back and forth requires other steps which you will have to learn. (i only have a vague understanding of the protocol). assuming you simply want to find some already created webrtc demo, you will need to find one that exposes these necessary steps. injecting the javascript to use front-facing or back-facing camera is trivial once you learn what you need to learn about webrtc.
Whaoo! Which webrtc link is that? If I can get only back camera, is enough for me. I will only need to make two buttons, opening default camera is already in front for one button while when I need back camera, I will just click on JavaScript button. I am not particular about switching front and back at all. This your own even looks so good, please, let me know how you got this and simple sample on JavaScript that gave you only back camera. It might be the solution or step forward towards acheiving my goal. If this one offers me what I want, I may discard Google's own
 
Upvote 0

omo

Active Member
Licensed User
This is a very good starting point for me to learn to build one, I will only have to worry about hosting server and if I can go beyond building peer-to-peer. Did you use the same command you taught me to switch to back camera? navigator.mediaDevices.getUserMedia

As for Google, I am not sure their JavaScript codes are exposed to get useful function that can change the camera. One more thing I will do is to download all .js in that their page and see if I will be lucky to to see related command. And I will also use the command to open back camera of the one you sent to me tomorrow by God's grace. Thank you so much for your unquenchable efforts
Regards
 
Upvote 0

drgottjr

Well-Known Member
Licensed User
look at the javascript; you'll see the command. better yet, study the webrtc documentation so you know what to look for. please.
 
Upvote 0
Top