cordova-rtc / cordova-plugin-iosrtc

Cordova iOS plugin exposing the WebRTC W3C API
MIT License
688 stars 340 forks source link

Add flashlight control #731

Open xulihang opened 2 years ago

xulihang commented 2 years ago

Versions affected Cordova version: 10.0.0 Cordova iOS version: Plugin version (e.g 6.0.12): 8.0.0 iOS version (e.g 10.2): 14.4.2 Xcode version (e.g 11.1 - 11A1027): 12.2 WebRTC-adapter version (e.g. 7.4.0): latest WebRTC Framework version (e.g. JSSip 3.1.2): ?

Description

Hi there,

I need to enable the flashlight (torch) while showing the camera preview in order to scan barcodes.

In Android, it is possible with the following code according to the media capture API:

const track = stream.getVideoTracks()[0];
track.applyConstraints({
        advanced: [{torch: true}]
      });

I wonder if it is possible to add such a flashlight control.

Thanks.

hthetiot commented 2 years ago

Hello,

This should be possible using example available here: https://stackoverflow.com/questions/27207278/how-to-turn-flashlight-on-and-off-in-swift/46313447

For now i don't have bandwidth to implement this feature, PR are welcome anyway.

hthetiot commented 2 years ago

There is already a cordova plugin for that:

Could be nice to make sure we play nice in term of compatibility.

streamsure commented 12 months ago

Hey folks, I've been tracking this for a very long time outside of this repository and it looks like the torch boolean is coming to native WKWebView shortly I believe!

Will the WebKit team monkey patch iOS16 or even 15? Wishful thinking I expect but I live in hope that Apple will do what's morally right and expose a fuller constraints list to support older iPhones.

I've emailed Eric today and will drop any tentative release expectations here as and when I receive a response. WebKit Torch Boolean Issue

hthetiot commented 12 months ago

Even if the Webview native implement it, does not mean iosrtc will have it. It will need to be exposed by iosrtc.