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

When to call torch function ? #13

Closed
christophedemey opened this issue Dec 7, 2019 · 3 comments
Closed

When to call torch function ? #13

christophedemey opened this issue Dec 7, 2019 · 3 comments
Labels
question Further information is requested

Comments

@christophedemey
Copy link

Hi

When the scanview is done loading there is no event to start the toggle of the camera.
Following your example i had to adapt like this else the toggleflashlight would throw a nullreferenceexception.

        public MainPage()
        {
            InitializeComponent();
            Task.Run(async() =>
            {
                await Task.Delay(5000);
                GoogleVisionBarCodeScanner.Methods.ToggleFlashlight();
            });
        }

        private async void CameraView_OnDetected(object sender, GoogleVisionBarCodeScanner.OnDetectedEventArg e)
        {
            List<GoogleVisionBarCodeScanner.BarcodeResult> obj = e.BarcodeResults;

            string result = string.Empty;
            for (int i = 0; i < obj.Count; i++)
            {
                result += $"{i + 1}. Type : {obj[i].BarcodeType}, Value : {obj[i].DisplayValue}{Environment.NewLine}";
            }
            Device.BeginInvokeOnMainThread(async () =>
            {
                await DisplayAlert("Result", result, "OK");
                //await Navigation.PopModalAsync();
            });
        }
@JimmyPun610
Copy link
Owner

ToggleFlashlight method have to call on the page that the camera is on.
Take the sample as an example, Page1.cs will have the implementation on it.

@christophedemey
Copy link
Author

Hi @JimmyPun610
I have checked the example which has a button, i want the torch to be on automatically when the camera is loaded.
When i try to do this while it's loading i get a nullreference exception.

How can i achieve this?

Thanks

@JimmyPun610 JimmyPun610 reopened this Dec 10, 2019
@JimmyPun610
Copy link
Owner

JimmyPun610 commented Dec 10, 2019

Hi @christophedemey
I updated the version to 4.2.1(uploading) and added a property named DefaultTorchOn
You may set it to true if you need to switch the light on when opening the page.
Please note that you will need to switch off the light in event OnDisappearing (You can refer to sample), otherwise, torch will not switch off in iOS.

Please let me know if it works, or you may close the issue. Thanks

@JimmyPun610 JimmyPun610 added the question Further information is requested label Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants