Capture Image from Webcam through js/JavaScript [duplicate] - javascript

This question already has answers here:
How can I capture an image via the user's webcam using getUserMedia?
(3 answers)
Closed 2 years ago.
I am looking to capture the image from the webcam.
I have tested quite a few libraries including
https://github.com/jhuckaby/webcamjs
https://github.com/amw/jpeg_camera
But all existing libraries are very old and no longer maintained by authors.
I have also tried "navigator.mediaDevices.getUserMedia" to capture the image but it does not work with safari.
I am wondering if you can suggest something that works cross-browsers and can manage a responsive view as well.
Thanks.

The navigator.mediaDevices.getUserMedia method should work with the latest version of safari 11. You'll want to use the MediaDevices.getUserMedia() method which has full support by almost every latest browser (except IE).
Note that if your writing an HTML file and opening it in the browser, it may not work because your browser may require a secure context (HTTPS instead of HTTP) to use that method.
See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
Also, Sam Dutton created a great example, and you can find the github code for it as well.

Related

Screensharing over WebRTC and browser support

I am trying to build screensharing over the browser. I am trying to find the best native implementation and did some initial online research
MediaDevices.getUserMedia() - available in FF. In chrome its a little weird
WebRTC Tab Content Capture - I see its in proposal stage
Screensharing a browser tab in HTML5 - A blog explaining other methods
Researching above everything seems to be around 2012 time frame and I want to know what is the latest?
Question: Which current technologies/javascript API can i use and what is its support across browsers
Screensharing is alive and kicking in Firefox, but atm requires the user modifying about:config. See my answer to another question for how. I believe they're working on removing that obstacle.
Chrome is similar but not quite the same, and AFAIK requires the user to install an extension.
I don't believe other browsers support this natively yet.
You can save html document onto <canvas> or <foreignObject> of <svg> element, then send data URL, ArrayBuffer or Blob of <canvas> or <svg>; or alternatively, send html document as encoded string.

how can a website detect smartphone model? [duplicate]

This question already has answers here:
Simple Smart Phone detection
(2 answers)
Closed 9 years ago.
How can a website detect the smartphone model of a device that requests a webpage?
Google Analytics can get that information as you can see in the image below:
I found this: http://blog.mobileesp.com/?p=177 but only a few phones are recognized by this script. I am looking for an PHP or Javascript solution
From Javascript you can read this property navigator.userAgent and PHP $_SERVER['HTTP_USER_AGENT'] both return you the browser version .
In my experience, the best method for detecting mobile/tablet is to use the PHP mobile_detect class which is updated regularly as new devices are released. Unfortunately, I don't know if it provides a way to get the different device types.
User agent parsing is the method you'll have to use, and if mobile_detect doesn't have it, it ought to at least give you a good starting point on how it's done.

Get Browser Version From Firefox Extension

I have written a Firefox extension and am currently in the process of updating it for Firefox 4 and adding some new features.
Firefox 4 has a great new notification display that I'd quite like to use and have found plenty of documentation on how to use it. However, for anything less than 4 I have created my own notification window with specific styles.
My question is: how can I detect whether I'm using Firefox 4 or not in the javascript for my extension. Or, is there a better way of doing this?
You can use nsIXULAppInfo:
var appInfo = Components.classes["#mozilla.org/xre/app-info;1"]
.getService(Components.interfaces.nsIXULAppInfo);
// appInfo.version contains the version
You can compare versions with nsIVersionComparator.
Maybe there is a better way, but this definitely works for me.
Following links will give you some idea how to do it.
http://bytes.com/topic/javascript/answers/822435-how-can-i-get-firefox-version
http://www.quirksmode.org/js/detect.html

Checking Flash player version using Javascript [duplicate]

This question already has answers here:
Cross Browser Flash Detection in Javascript
(16 answers)
Closed 7 years ago.
Is it possible to check the version of the Flash Player installed in a browser using Javascript?
You can check an example here.
There is a nice, lightweight JavaScript Flash Detection Library, which is smaller and more convenient than using SWFObject. You should consider it, if you only want to check if Flash is installed, what version of Flash Player is installed etc., but you're using different method of playing FLV movies.
SWFObject should be considered only, if you're also using it for playing Flash movies. For just checking, if Flash is installed or what version of Flash player is installed, it is to heavy, in my opinion.
You should have a look at swfobject2: http://code.google.com/p/swfobject/

Embedding Flash & Quicktime Via JavaScript

I have a JavaScript function that loads a flash movie into a webpage div using swfobject.embedSWF().
I want to be able to, alternatively, load a .mov file into the same div, in the event that this is the file found instead of the .swf.
Is there a close equivalent to swfobject.embedSWF for the purposes of embedding a .mov file? If not, what is an efficient route to doing this using JavaScript?
QTObject might do what you need and it's from the same author as SWFObject. It's old though, so I'm not sure if it will work well in modern browsers.
EDIT I searched and found reports of it working fine in IE7, Firefox 2 and Opera 9, so you might just be in luck. Just make sure you test it thoroughly.

Categories