Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 video not working: permission denied #250

Open
esiokugbechoice opened this issue May 25, 2022 · 3 comments
Open

HTML5 video not working: permission denied #250

esiokugbechoice opened this issue May 25, 2022 · 3 comments

Comments

@esiokugbechoice
Copy link

I am using an HTML5 QR code reader https://github.com/mebjas/html5-qrcode. everything works fine on chrome, but I get the following error when i try from the webview





Please help...

@husaindevelop
Copy link

The camera's permission is disabled, that's why you are getting this error. Simply follow the code given below, the camera will start working as well as your scanner which depends on it.

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.

@Macof08
Copy link

Macof08 commented Apr 11, 2023

i got the same problem and @husaindevelop, i put your code but give me error when i build app.

error: cannot find symbol
public void onPermissionRequest(@NotNull final PermissionRequest request) {
^
symbol: class PermissionRequest

@mgks any idea?

@frogsuite
Copy link

replace @NotNull with @nullable
also import
import androidx.annotation.NonNull;
import org.jetbrains.annotations.Nullable;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants