(JS) For , determine if the device offers or not to capture a photo from the camera

Mobile Technologies Mobile Computing 2 years ago

0 0 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ When uploading a file, I need to give the user the possibility: upload the file from the file-system capture a photo from the camera Simply using input type="file", that behavior is implemented by most of the browser-devices pairs, but not by all of them (see that answer for details: https://stackoverflow.com/a/33414310). Those pairs that don't implement the photo capture are probably only about computer devices, but I'm not 100% sure of that (maybe some browsers on computer devices do implement the photo capture, maybe some browsers on non-computer devices don't). To make up for that lack on such devices, I use a library to have: one input type="file" to upload file from file-system, + for certain devices: to capture file from camera one special button calling the library to capture photo That library fulffils others tasks and is nicely integrated to my upload system. Also, I use it for a long time now, so to change it might introduce regressions. To conclude: I would prefer to keep it. On the other hand, for devices that allow the photo capture, that library performs less than the device photo capture. For example, it does not offer the possibility to switch between front and back cameras. That's why, to capture photos, I need to use that library only for devices that don't implement the photo capture. In other words: I need to determine if a device implements or not the photo capture via input type="file" I found many many answers to determine if the browser is mobile or not, but no one is satisfying. The most interesting thread was: How to test if the browser support . Unfortunately, that solution is not perfect: it's not because the "capture" property is not available for an input element, that the browser and the device does not offer the possibility to capture a photo via the input element. It only means that it's not possible to force capturing a photo from the camera instead of uploading a file from the filesystem. But it does not mean the capture from the camera is not possible. However, after reading documentations I found it's highly related... ...but after some tests, I found a counter-exemple: on a Samsung tablet, Firefox tells me the "capture" property is not available for input, but the browser offers to capture a photo via the input element after all. Any help? :)

Posted on 16 Aug 2022, this text provides information on Mobile Computing related to Mobile Technologies. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Mobile Technologies Links