1

The following code turns the torch/flash on or off using JavaScript inside browser.
VideoStream derived from navigator.mediaDevices.getUserMedia

VideoStream.applyConstraints({            advanced: [{ torch: state }]
                });

//Where VideoStream points to the camera stream/track, state = true (on) or false (off)

I have tested and works perfectly on Android, but on latest iOS it doesnt work. Can anyone tell me if there is a workaround/alternative, or is this a "live with it"?

Vinnie Amir
  • 557
  • 5
  • 10
  • I think the question desperately lacks detail. What are `VideoStream` and its `applyConstraints`? Which native APIs (for both Android and iOS) does it call? I think only knowing, which iOS SDK methods are called would let one find out where the problem lies. – lazarevzubov Feb 10 '22 at 07:17
  • I edited the question for clarity. Also fyi I don't know of any JavaScript that runs natively on iOS, only in browsers. Hence why I didn't include this obvious piece of info. Thanks for your reply nonetheless. – Vinnie Amir Feb 11 '22 at 08:20
  • Thanks! Previously it wasn't clear, how and where do you call this piece of code. Then, what about `VideoStream` and its method? If it's some library's class and you use it as described in its documentation, then probably it's good to ask the library maintainers or file a bug report for them. If it's your method and you have control over its implementation, then please share it. Without knowing the implementation of a method it's impossible to say, why it's not working. – lazarevzubov Feb 11 '22 at 08:34
  • 1
    OK, I searched a little and found several relevant discussions: https://stackoverflow.com/questions/61814177/nodejs-turn-on-and-off-tourch-flashlight-in-mobile-android-iphone , https://stackoverflow.com/questions/68786850/turn-on-phone-flashlight-on-web-app-using-javascript-and-html , https://stackoverflow.com/questions/37848494/is-it-possible-to-control-the-camera-light-on-a-phone-via-a-website . It seems they all conclude the same thing: iOS doesn't provide (didn't implement) access to the flashlight from browsers (neither Chrome, nor even Safari). So, I guess it's a "live with it" thing. – lazarevzubov Feb 11 '22 at 08:40

0 Answers0