Sample - Getusermediacamera

The sample -getusermediacamera is not working at android after phonegap native compilation

error:
Notreadable error: could not start video source

Any idea?

Where does this error appear?

if you hook up the Chrome Remote Debugger, is there more?

Share your story with the AppStudio Community! Quarantine Stories

it appear once the app started in android phone.

Sub Main()
  context = PictureBox1.getContext("2d")
  videoObj = {"video": True}
  
  'Put video listeners into place
  If (navigator.webkitGetUserMedia) Then
    navigator.webkitGetUserMedia(videoObj, videoBack, errBack);
  End If
End Sub

Sub errBack(error)
  MsgBox "Video capture error: " & error
End Sub

if i run the sample app in desktop, i can see the camera light is turn on at my notebook

if you hook up the Chrome Remote Debugger, is there more?

Share your story with the AppStudio Community! Quarantine Stories

chrome remote debugger:
refused to load the image 'android-webview-video-…
because it violates the following content security policy directive: “img-src * data:”

This one has come up before. If you do a search here or in our blog, you’ll see a number of articles:

https://blog.appstudio.dev/2015/12/phonegap-no-content-security-policy-message/

https://discuss.appstudio.dev/search?q=content%20security%20policy%20phonegap

Share your story with the AppStudio Community! Quarantine Stories

i dont really understand what should i put in CSP, i tried as other suggestions

img-src * data: blob: android-webview-video-poster:;
img-src ‘self’ data: content:;
none of them are working

in additional, from other suggestion
in order to webrtc to work in android, then following premissions need to be added in config.xml

uses-permission android:name=“android.permission.CAMERA”
uses-permission android:name=“android.permission.WRITE_EXTERNAL_STORAGE”
uses-permission android:name=“android.permission.RECORD_AUDIO”

how can i add these premission into config.xml?

Please advise

Thanks

Did you set permissions?

no, i dont know where to place the permission statements.

ie: i place the statement before , but phonegap return source error while compiling

Thanks
Teo

Put it in the contentSecurityPolicy in Project Properties (in the PhoneGap section):

Here are a couple more complex ones:

default-src 'self' gap://ready file:; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src 'self'; img-src 'self'; connect-src https://*.XXXX.ie tel:;

default-src 'self' gap://ready file: https://fonts.googleapis.com https://fonts.gstatic.com; 
style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; 
script-src 'self' 'unsafe-inline' 'unsafe-eval' https://developers.google.com https://maps.googleapis.com https: ;
media-src 'self' data: file: ; 
img-src 'self' data: android-webview-video-poster: ; 
connect-src https://api.XXXX.com https://apidev.XXXX.com/ blob: file: data: https:

no, both are not working either as same error message

Thanks
Teo

I would not expect either of these to work in your situation. They are meant as samples which might give you ideas for what you need.

@dkteo did you get this working?

@PPetree, no, i have tried most of the possible values in CSP, but none of them are working.
btw, is that because my phone is android 8.01

In your original post, you say this…

Is that the complete message? The 3 dots after 'android-webview-video- look odd.

@dkteo if you look here You’ll see that iOS 11 is the first iOS version to support WebRTC.

You can still get the code working in Chrome until you can find a later iOS version to test on.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.