webcam not loading, displays error: Webcamjs error: Could not access webcam: NotallowedError: Permission denied
Describe the bug Webcam does not load. It throws up error: "Webcam.js error, could not access webcam: Notallowed error"
A clear and concise description of what the bug is, better if you can attach a log. We imported your project, changed asw url and linked it to our getusermedia example page, which is a working example in all modern browsers. Upon initialization of app, the error pops up: "Webcam.js error, could not access webcam: Notallowed error"
Expected behavior The webcam should load correctly without the aforesaid error.
Screenshots

Device (please complete the following information):
-
Device name/variant: [e.g. Samsung Galaxy, J2] Samsung Galaxy S10
-
Build [e.g. arm, x86] x86
-
Android Version [e.g. API 27 or Oreo] 29, not sure
Additional context Add any other context about the problem here.
We need WebRTC feature to achieve that - this link might help you.
If i'm right, Process Camera Input is part of this project. How's that different from getusermedia api ?
And if you do not mind, could you please inject the code given in the reference link in the project's MainActivity.Java file. Since i'm not actually a pro in android and java language, its quite time consuming and difficult to actually pick a code and insert it into the appropriate line of the project.
I already got the request to do so but it's not just a matter of copying and pasting the code from there to here. SWV is getting more complex with each new request, so every single change brings a new issue and currently I'm kind of busy procrastinating, I'm sorry but it's a slow process and I don't know when I'm going to touch this subject.
Meanwhile, you're free to experiment and if you did it before us, do let us know how you did it. It might help a lot of people here. :)
I understand and appreciate. I shall try the code given in the reference link. Not trying to impose on you, but atleast give me a pointer as where i should inject this code.
Based on what i presume, its probably in 894 line of Mainactivity.java
is the webcam issue resolved ?
Its resolved. Here is the solution for all of those who are struggling with the current issue. Thanks to the aws android sample webview, i was able to take out its codes and implement in the smart webview. So here it is
Under MainActivity.Java file / asw_view.SetwebChromeClient. Post this code
@Nullable
public Bitmap getDefaultVideoPoster() {
return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
}
@Override
public void onPermissionRequest(@NotNull final PermissionRequest request) {
final String[] requestedResources = request.getResources();
for (String r : requestedResources) {
if (r.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) {
request.grant(new String[]{PermissionRequest.RESOURCE_VIDEO_CAPTURE});
break;
}
if (r.equals(PermissionRequest.RESOURCE_AUDIO_CAPTURE)) {
request.grant(new String[] { PermissionRequest.RESOURCE_AUDIO_CAPTURE});
break;
}
}
}
Add the line under websettings
webSettings.setMediaPlaybackRequiresUserGesture(false);
And make sure record_audio and camera permissions are granted in android manifest xml. Any issues on this, any of you can message me. Thanks.
Its resolved. Here is the solution for all of those who are struggling with the current issue. Thanks to the aws android sample webview, i was able to take out its codes and implement in the smart webview. So here it is
Under MainActivity.Java file / asw_view.SetwebChromeClient. Post this code
@Nullable public Bitmap getDefaultVideoPoster() { return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888); } @Override public void onPermissionRequest(@NotNull final PermissionRequest request) { final String[] requestedResources = request.getResources(); for (String r : requestedResources) { if (r.equals(PermissionRequest.RESOURCE_VIDEO_CAPTURE)) { request.grant(new String[]{PermissionRequest.RESOURCE_VIDEO_CAPTURE}); break; } if (r.equals(PermissionRequest.RESOURCE_AUDIO_CAPTURE)) { request.grant(new String[] { PermissionRequest.RESOURCE_AUDIO_CAPTURE}); break; } } }Add the line under websettings
webSettings.setMediaPlaybackRequiresUserGesture(false);And make sure record_audio and camera permissions are granted in android manifest xml. Any issues on this, any of you can message me. Thanks.
Its very helpful thanks you brother. iam just adding webSettings.setMediaPlaybackRequiresUserGesture(false); and boom, its work
Hello There, I am facing same issue. I used the web view for my flutter app,The camera working properly in my website but getting this error in Android and iOS. Also can't able to MainActivity.java file so please help that how can solve it ?