You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Permission Camera & androidStudio Build Error #473
Hi, I'm trying to using your webview plugin.
it can be show webpage, but Can't show popup message(allow camera and microphone) and access permission camera.
so i read #360 , and download zip file, open android studio. (open file path is /plugins/Android )
but i see this error -
Gradle Sync Issues - ERROR: Cannot read packageName from C:\Users\Q\Desktop\unity-webview-master\plugins\Android\gradle_build\src\main\AndroidManifest.xml
can i get update plugin ? ( please update for access permission camera. current project can't access camera via webpage.)
Thank you for your reply my comment. so i update from your plugin(just execute /dist in unity-webview.unitypackage) and build and run my project. not modify script.
but same state - can't show popup message(allow camera permission).
what I need to add my script? show this code in my script.
if i join from Computer browser(Chrome) above address, show popup message( are you allow camera permission? ).
but if i join from android unity project, it can't show popup message.
how can i show popup message for allow camera?
Okay, i finally success using webview - Video Chat. (tested from https://appr.tc/ , and add audio.)
but if i end video chat, using "SetVisibility(false)" , my camera rendering is stopped. maybe remain working on background apprtc...
and i tried to using "Destroy" component, unfortunately same state.
so how can i stop webview and restart rendering my camera?
The last code doesn't work if the target api is 23 or later, so I've fixed further in #477 and updated binaries. I'm not sure how you solved the issue for Video Chat, but a whole webview should be destroyed if you destroy the GameObject (cf.
i read your reply, and Update from "unitypackage".
and If i access camera, my application turn off by force. your sample app also.(change url and tested).
maybe this phenomenon is wrong update. please check your updated binaries.
(I think this phenomenon is relation by camera permission.)
RealWear HMT -1 (Android API is 8.1)
and using Vuforia AR Camera.
so i follow your test.
i tested not need Camera page(like https://www.google.com/ )
if i access google page, it's perfectly work.
but.. if i access need Camera Page, like above your test url, my application is shut down.
Okay... I Think My Project is wrong..
I make new project, and Test Your plugin. and it's work... (but Can't see camera view. i don't know)
but if i destroy webviewobject, Unity camera is stopped.
how do i restart rendering Unity Camera?
By pressing this * button, the sample app shows the camera view again when the webview is recreated (I tested the sample app for https://davidwalsh.name/demo/camera.php with Unity 2019.2.6f1 -- BTW I typo'd my Unity version in #473 (comment) so I edited the comment).
If you want to stop/start the camera without destroying the webview, you might need to directly control the web content through EvaluateJS().
Also, it might be better to request the permission at start and/or just before creating the webview, as requesting the permission when the webview requests it may be too late (the webview continues to run while the permission dialog is displayed). The following is an example modification for the sample app.
diff --git a/sample/Assets/Scripts/SampleWebView.cs b/sample/Assets/Scripts/SampleWebView.cs
index a62c1ca..a5efe9f 100644
--- a/sample/Assets/Scripts/SampleWebView.cs+++ b/sample/Assets/Scripts/SampleWebView.cs@@ -24,6 +24,9 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;
#endif
+#if !UNITY_EDITOR && UNITY_ANDROID+using UnityEngine.Android;+#endif
public class SampleWebView : MonoBehaviour
{
@@ -31,8 +34,29 @@ public class SampleWebView : MonoBehaviour
public GUIText status;
WebViewObject webViewObject;
+#if !UNITY_EDITOR && UNITY_ANDROID+ bool inRequestingCameraPermission;++ void OnApplicationFocus(bool hasFocus)+ {+ if (inRequestingCameraPermission && hasFocus) {+ inRequestingCameraPermission = false;+ }+ }+#endif+
IEnumerator Start()
{
+#if !UNITY_EDITOR && UNITY_ANDROID+ if (!Permission.HasUserAuthorizedPermission(Permission.Camera))+ {+ inRequestingCameraPermission = true;+ Permission.RequestUserPermission(Permission.Camera);+ } + while (inRequestingCameraPermission) {+ yield return new WaitForSeconds(0.5f);+ }+#endif
webViewObject = (new GameObject("WebViewObject")).AddComponent<WebViewObject>();
webViewObject.Init(
cb: (msg) =>
If it is okay, I would like to revert 662142d as the above approach is more straightforward and doesn't require to include extra aar files.
also consider my situation - i'm using Vuforia AR Camera, so Camera rendering is already use.
already use camera state, pressed button( so previous rendering camera is stopped and webview rendering camera(in video chat camera) is on. if you have enough time, tested it. )
so i asked 'how do i restart rendering Unity Camera?'
i don't test above your comments, that is helpful for me...? ( i will test your comment ASAP )
or using multiple camera( one is ARCamera, another is default camera), should i change my camera when I need each one?
thank you for comments and spending your time for me.
These could be utilized to stop Vuforia and/or its camera before opening the webview and to restart Vuforia and/or its camera after closing the webview.
Finally successed VideoChat!. (I hope my project will be no errors next time.)
update your plugin and if i start VideoChat(start Visible true webView), stop ARCamera.
and if i end VideoChat, Destroy WebviewComponent and start ARCamera.
also, my project is already access camera permission , so i don't have to set Define Symbols.
Maybe i think that before errer(if i start videochat, forced exit my app) is duplicate permission camera. maybe....
Thank you for your helpful mind and your spent time.
P.S. i think next update will added permission microphone. it just my idea.
Activity
KojiNakamaru commentedon Nov 27, 2019
Building the plugin for Android requires Unity's classes.jar so some special steps are required (cf. https://github.com/gree/unity-webview/tree/d380b1bb2564d73b55f169accb5135e3ee218a8d#how-to-build-webviewpluginjar ).
I however thought #360 was okay to be merged, so I merged it and updated binaries on the master branch. Though I haven't tested it, could you please try the latest?
KiDeokKim commentedon Nov 27, 2019
Thank you for your reply my comment. so i update from your plugin(just execute /dist in unity-webview.unitypackage) and build and run my project. not modify script.
but same state - can't show popup message(allow camera permission).
what I need to add my script? show this code in my script.
test address is #359 's address
WebViewObject webViewObject =
(new GameObject("WebViewObject")).AddComponent();
webViewObject.Init((msg) =>
{
Debug.Log(string.Format("CallFromJS[{0}]", msg));
});
webViewObject.LoadURL(address);
webViewObject.SetVisibility(true);
if i join from Computer browser(Chrome) above address, show popup message( are you allow camera permission? ).
but if i join from android unity project, it can't show popup message.
how can i show popup message for allow camera?
KiDeokKim commentedon Nov 27, 2019
Okay, i finally success using webview - Video Chat. (tested from https://appr.tc/ , and add audio.)
but if i end video chat, using "SetVisibility(false)" , my camera rendering is stopped. maybe remain working on background apprtc...
and i tried to using "Destroy" component, unfortunately same state.
so how can i stop webview and restart rendering my camera?
KojiNakamaru commentedon Nov 27, 2019
The last code doesn't work if the target api is 23 or later, so I've fixed further in #477 and updated binaries. I'm not sure how you solved the issue for Video Chat, but a whole webview should be destroyed if you destroy the GameObject (cf.
unity-webview/sample/Assets/Scripts/SampleWebView.cs
Lines 169 to 171 in 4b720b5
KiDeokKim commentedon Nov 27, 2019
i read your reply, and Update from "unitypackage".
and If i access camera, my application turn off by force. your sample app also.(change url and tested).
maybe this phenomenon is wrong update. please check your updated binaries.
(I think this phenomenon is relation by camera permission.)
KojiNakamaru commentedon Nov 28, 2019
I tested for the sample app with the following setting.
and at least the app showed the page. Camera permission/feature is added to AndroidManifest.xml by defining
UNITYWEBVIEW_ANDROID_ENABLE_CAMERA(cf. https://github.com/gree/unity-webview/tree/f5bff470041dd07f97a3f97d30fa03820a2af545#camera-permissionfeature ) as below.Could you please tell me your environment? My environment is:
2019.2.3f12019.2.13f1KiDeokKim commentedon Nov 28, 2019
My environment is :
and using Vuforia AR Camera.
so i follow your test.

i tested not need Camera page(like https://www.google.com/ )
if i access google page, it's perfectly work.
but.. if i access need Camera Page, like above your test url, my application is shut down.
KiDeokKim commentedon Nov 28, 2019
Okay... I Think My Project is wrong..
I make new project, and Test Your plugin. and it's work... (but Can't see camera view. i don't know)
but if i destroy webviewobject, Unity camera is stopped.
how do i restart rendering Unity Camera?
KojiNakamaru commentedon Nov 28, 2019
The sample app has a button to destroy/create the webview:
unity-webview/sample/Assets/Scripts/SampleWebView.cs
Lines 172 to 179 in 681fa44
By pressing this
*button, the sample app shows the camera view again when the webview is recreated (I tested the sample app for https://davidwalsh.name/demo/camera.php with Unity 2019.2.6f1 -- BTW I typo'd my Unity version in #473 (comment) so I edited the comment).If you want to stop/start the camera without destroying the webview, you might need to directly control the web content through
EvaluateJS().Also, it might be better to request the permission at start and/or just before creating the webview, as requesting the permission when the webview requests it may be too late (the webview continues to run while the permission dialog is displayed). The following is an example modification for the sample app.
If it is okay, I would like to revert 662142d as the above approach is more straightforward and doesn't require to include extra aar files.
KiDeokKim commentedon Nov 28, 2019
also consider my situation - i'm using Vuforia AR Camera, so Camera rendering is already use.
already use camera state, pressed button( so previous rendering camera is stopped and webview rendering camera(in video chat camera) is on. if you have enough time, tested it. )
so i asked 'how do i restart rendering Unity Camera?'
i don't test above your comments, that is helpful for me...? ( i will test your comment ASAP )
or using multiple camera( one is ARCamera, another is default camera), should i change my camera when I need each one?
thank you for comments and spending your time for me.
KojiNakamaru commentedon Nov 28, 2019
I have no experience about Vuforia, but it seems to have CameraDevice API:
https://library.vuforia.com/content/vuforia-library/en/reference/unity/classVuforia_1_1CameraDevice.html#aa70efaa4751ac6d5d54dce88fe725e0a
and there are some discussions about CameraDevice and VuforiaBehavior:
https://stackoverflow.com/questions/49925576/how-to-switch-change-front-and-back-vuforia-ar-camera-using-a-button/49975991#49975991
https://stackoverflow.com/questions/47000398/how-to-stop-vuforia-behaviour/58829640#58829640
These could be utilized to stop Vuforia and/or its camera before opening the webview and to restart Vuforia and/or its camera after closing the webview.
reverted 662142d (cf. #473 (comment)).
KiDeokKim commentedon Nov 30, 2019
Finally successed VideoChat!. (I hope my project will be no errors next time.)
update your plugin and if i start VideoChat(start Visible true webView), stop ARCamera.
and if i end VideoChat, Destroy WebviewComponent and start ARCamera.
also, my project is already access camera permission , so i don't have to set Define Symbols.
Maybe i think that before errer(if i start videochat, forced exit my app) is duplicate permission camera. maybe....
Thank you for your helpful mind and your spent time.
P.S. i think next update will added permission microphone. it just my idea.
KojiNakamaru commentedon Dec 2, 2019
Thanks! I'll later add the permission.
added android audio support (cf. #473 (comment) ).