-
Notifications
You must be signed in to change notification settings - Fork 340
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
Why torch is always not supported? #397
Comments
The issue is that Apple does not implement the browser API to control the flash light. |
Sadly, no.
I setup a simple demo that should allow you to confirm whether torch is supported on a device or not. Note that it might be supported for a rear camera but not the front camera or something (even if the front camera is equipped with a flashlight). Go on this page with our device: https://vue-qrcode-reader.netlify.app/select-camera-demo.html The list of links represents all cameras installed on the device. If you click, the camera should be loaded. Below the camera view the JSON object of "capabilities" should be printed. If it doesn't contain the key/value pair
Hmm, what do you mean? From your screenshot it looks like it does work. |
Hi, I have uploaded a video: The Chrome is the latest version in Google Play which updated by 2023-12-12. 49.MOV |
Is there a official document by Apple? |
We can communicate in Chinese which will be more efficient if it's okay by you. If this is something that should be fixed in this repo I'll push a fix to let you know. @gruhn @magic3584 Hello,我们可以用中文沟通,你可以讲一下你手机的 iOS 系统版本吗?以及你那里有没有条件可以查看手机浏览器的控制台输出?(应该是需要一个 Mac 支持) |
@Sec-ant 可以的 可以用 Mac Safari 查看手机浏览器输出 |
@magic3584 那么你用这两台设备分别访问 https://vue-qrcode-reader.netlify.app/demos/Torch.html 和 https://vue-qrcode-reader.netlify.app/select-camera-demo.html 这两个网页时,控制台有没有输出什么信息?(安卓可以考虑用 kiwi 浏览器查看控制台,或者用 ADB) 还有上面这两个 vue-qrcode-reader.netlify.app 页面都需要获取摄像头权限,但是你的视频 demo 里面似乎也没有请求权限这一过程,是已经同意过了吗?如果没有的话需要重新允许一下权限。 为了避免其它干扰,我还建议先尝试清除 vue-qrcode-reader.netlify.app 这个域名下的缓存再重新访问测试。 |
iOS 上的话,访问这两个网页控制台都没有任何输出。 Capabilities:
{
"aspectRatio": {
"max": 4032,
"min": 0.00033068783068783067
},
"deviceId": "B579",
"facingMode": [
"environment"
],
"frameRate": {
"max": 60,
"min": 1
},
"height": {
"max": 3024,
"min": 1
},
"width": {
"max": 4032,
"min": 1
}
} android 的我不太熟,稍等我琢磨下。。。 |
这个显示的文字代表设备/浏览器所允许当前相机配置的功能(capabilities),如果里面没有 "torch": true 选项,就代表设备或浏览器不支持对闪光灯/手电筒进行配置。点击网页上方的显示出来的相机链接可以切换相机,查看不同相机的 capabilities ,如果都没有 "torch": true 这一选项,那么就代表都不支持。这个浏览器 API 层面如果不支持的话是没办法修复的。 关于 iOS 使用 Torch 功能相关的讨论(我不清楚最新版本是否支持): 安卓端也是相同的道理,但支持程度比 iOS 要高很多,不过你的 demo 里面安卓端访问 select-camera-demo.html 是白屏有点奇怪。。 |
https://vue-qrcode-reader.netlify.app/demos/Torch.html 结果: 第一次正常预览的时候控制台输出 {
"aspectRatio": {
"max": 2592,
"min": 0.0005154639175257732
},
"colorTemperature": {
"max": 7000,
"min": 2850,
"step": 50
},
"deviceId": "d9892de56",
"exposureCompensation": {
"max": 4,
"min": -4,
"step": 0.1666666716337204
},
"exposureMode": [
"continuous",
"manual"
],
"exposureTime": {
"max": 10534,
"min": 0,
"step": 0
},
"facingMode": [
"user"
],
"focusDistance": {
"max": 2.751004695892334,
"min": 0,
"step": 0.009999999776482582
},
"focusMode": [
"manual"
],
"frameRate": {
"max": 30,
"min": 0
},
"groupId": "681b8989b764537c15887cd0d1105",
"height": {
"max": 1940,
"min": 1
},
"iso": {
"max": 800,
"min": 50,
"step": 1
},
"resizeMode": [
"none",
"crop-and-scale"
],
"whiteBalanceMode": [
"continuous",
"manual"
],
"width": {
"max": 2592,
"min": 1
},
"zoom": {
"max": 10,
"min": 1,
"step": 0.1
}
} https://vue-qrcode-reader.netlify.app/select-camera-demo.html 结果: |
@Sec-ant |
摄像头允许调用的能力同时取决于浏览器、平台和设备,iOS + Safari 是支持获取摄像头能力这一接口的( 我不清楚这个有没有官方文档支持(目前看来是没有的),而且浏览器、平台、设备互相之间差异巨大,不太可能有一个统一的标准,这个接口的标准调用流程就是要在调用时先检查当前摄像头支持哪些能力:https://developer.mozilla.org/en-US/docs/Web/API/Media_Capture_and_Streams_API/Constraints#overview 苹果返回回来的结果不支持 torch 那就没有其它办法了,因为它没有把这项能力提供给浏览器让开发者调用。 那个上面安卓的问题我觉得可以另开一个 issue。 |
如果整个 iOS平台都无法实现,我得在项目里抛出这个问题了。。。 |
这个库目前用的二维码识别核心部分是我的
|
@gruhn I think we can close this. But do you know if it is true that the latest iOS still doesn't support torch capability on the newest devices? And do you think we should put this in |
大佬我现在用这个库还发现有问题:
|
@magic3584 如果是这个仓库的问题,新开一个 issue,附上能够复现的操作步骤和条码。 |
I haven’t found an official source. But mu iPhone is on iOS 17.1 and it’s still not supported.
That’s a good idea 👍 |
就随便生成一个 codebar 也扫不出来。 |
两个问题:
|
@Sec-ant 抱歉我的错,通过 #379 (comment) 解决了。我认为应该把默认只识别二维码写在 README 里。 @gruhn |
@Sec-ant 至于android白屏幕问题,就跟这个 issue 无关了。。。 再次感谢。 |
I run https://vue-qrcode-reader.netlify.app/demos/Torch.html on iPhone 12, but it always show torchNotSupported. And iPhone does has a flashlight.
The text was updated successfully, but these errors were encountered: