0

Hello, i use a script that allows a user to take a photo. I use a Shockwave Flash Object (.swf) to open the camera and i don't want to do this.

How can i do it by callin' the browser prompt that ask you to open the camera?

This is how i call the .swf file

if(ID=='webcamButton')
        {
            $("#webcam").html("");
            $("#webcamContainer").fadeIn();
            $("#webcam").webcam({
            width: 320,
            height: 240,
            mode: "callback",
            swffile: baseUrl+"js/jscam_canvas_only.swf",
            onSave: saveCB,
            onCapture: function ()
            {
            webcam.save();
            },
            debug: function (type, string) {
            $("#webcam_status").html(type + ": " + string);
            }
            });
        }
 return false;
    });
3
Contributors
18
Replies
92
Views
3 Months
Discussion Span
Last Post by gentlemedia
Featured Replies
  • IE and Safari (why not test with Edge?) are problematic browsers. All we need to do is check caniuse.com and well, that's a deep well and Jimmy keeps getting stuck in the well. -> At this point you have a solved for most browsers and have to see if this … Read More

  • `MediaDevices.getUserMedia()` which falls under the Media Capture and Streams specification is not supported (yet) in Safari (desktop and mobile), but is in development. https://webkit.org/status/?#specification-media-capture-and-streams So you will have to create indeed a fallback solution for Safari. Read More

  • You can use this tiny library to detect WebRTC features such as getUserMedia so you can serve your fallback solution for those browsers which don't support it. https://github.com/muaz-khan/DetectRTC Read More

  • @rprofitt - Each browser vendor has it's own platform status page, so if you can't find it via caniuse, you can check them out too. Blink (Chrome & Opera) - https://www.chromestatus.com/features Firefox - https://platform-status.mozilla.org/ Edge - https://developer.microsoft.com/en-us/microsoft-edge/platform/status/ Read More

0

Thanks @GentleMedia. The article on the last comment is marked as Deprecated though.

0

The article on the last comment is marked as Deprecated though.

Indeed! And that's why I posted that link to that article in that last comment to show that Navigator.getUserMedia() is deprecated and to use MediaDevices.getUserMedia() instead :)

Edited by gentlemedia

0

I want to ask another thing. Why the .swf file doesn't play online ? Locally plays as wanted. Its a Flash thing, right?

I am trying to implement it to my existing code. Ι want to take the id of the photo taken so that i can pass it to my php code to save it. but i am getting errors

$("body").on("click",'.updateControl2',function()
    {
    var video = document.getElementById('webcamButton');
    if(video)
    {
            $("#webcam").html("");
            $("#webcamContainer").fadeIn();
            $("#webcam").webcam({
            width: 320,
            height: 240,
            // Get access to the camera!
                // Not adding `{ audio: true }` since we only want video now
                navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
                    video.src = window.URL.createObjectURL(stream);
                    video.play();
                }),
            onSave: saveCB,
            onCapture: function ()
            {
            webcam.save();
            },
            debug: function (type, string) {
            $("#webcam_status").html(type + ": " + string);
            }
            });
        }
 return false;
    });
<div id="webcam_preview"></div>
            <a href="javascript:void(0);" class="updateControl2" id="webcamButton" title="Open Camera"><span class="boxWebcam wallbutton">Open Camera</span></a><br /><br /><br />
                <div class="padding10 blockControl displaynone" id="webcamContainer">
                    <div>
                        <div id="webcam">
                        </div>
                    </div>
                    <div id='webcam_status' style="clear:both" ></div>
                    <div id='webcam_takesnap'>
                        <input type="button" value=" Take a Photo " id="takeSnap" class="camclick  wallbutton"/>
                        <input type="hidden" id="webcam_count" />
                    </div>
                </div>
            </div>
0

@Sim. I think this is an extension of another open thread you have going.

I'm guessing you want to do this to thwart fake registrations but as we can fake the camera (example at https://github.com/GhostFlying/image-to-camera ) then I can be anyone I want to be.

I'm not writing you should not follow your dreams, I'm writing that you need to think if it's all worth the trouble since it can be easily subverted.

0

I dont want to make a fake camera for an app. My project is a responsive website. I want a script that opens the camera and takes a photo. Not video.

0

What you want may not be possible in all browsers and machines. That's one of our Holy Grail quests.

Somewhere you wrote this was to thwart fake registrations but I wanted to counter that it would be trivial for me to have a fake camera on my device to give you a false image. So you do all this work and folk can easily defeat it.

https://developers.google.com/web/fundamentals/native-hardware/capturing-images/ tells me you will not reach your goal of "Not video." I hope you'll read the link in this paragraph to see why you must open the camera and the user take the shot.

0

It works on Chrome, Mozilla, Opera but not on Safari and IE. I guess i was looking for the Holy Grail!

0

I think you're getting it now. Be sure to see how the search for the Holy Grail ended in the movie by Monty Python.

0

I understand it, i just wanted to see it for my self. What happens in the end? i watched that movie 20 years ago. John Gleeze and the Monty Pythons were great. I mean is there a metaphore for cross browsing?

Edited by SimonIoa

0

Cross browsing? I think you meant the old topic of Browser and Platform Compatibility. I've seen such quests and if you don't maintain a sense of humor and accept this as a silly quest you may be institionalized. Which is why I referenced the end of the Quest for the Holy Grail.

Votes + Comments
+1 because somebody down-voted it probably because there is some humor in it
0

If i haven't had a sense of humor i could be offended by this. Anyway this goes off topic. I see nothing wrong about asking here and hoping to get something more. One may not knew that a script like this could play in all browsers.

1

IE and Safari (why not test with Edge?) are problematic browsers. All we need to do is check caniuse.com and well, that's a deep well and Jimmy keeps getting stuck in the well.

-> At this point you have a solved for most browsers and have to see if this is, in the case of Safari something Apple just doesn't allow. One of the common complaints about Safari I've fielded is autoplay of videos. Apple relaxed that last year at https://webkit.org/blog/6784/new-video-policies-for-ios/

So be sure you are not beating your head against a Safari bulkhead.

0

It works on Edge too.

I want to ask one last thing. @gentleMedia said earlier that Navigator.getUserMedia() is deprecated and to use MediaDevices.getUserMedia() instead. navigator.mediaDevices.getUserMedia seems to be a global -if i am sayin this right- variable and when i replace navigator.mediaDevices.getUserMedia({video: true}) with MediaDevices.getUserMedia({video: true}) i am getting ReferenceError: Can't find variable: mediaDevices on Safari inspect element but when i use navigator.mediaDevices.getUserMedia({video: true}) i get TypeError: 'undefined' is not an object (evaluating 'navigator.mediaDevices.getUserMedia') on console

Same error i am getting when i am tryin to use a WebRTC script for capturing video

Edited by SimonIoa

0

My advice is to close this topic as solved and start a new thread asking "How to capture image with Safari" and add the rest of your requirements.

Later in your script you use your browser detection to use the Chrome, IE, Edge and such code for those browsers and Safari code for Safari.

I would take bets you won't find one code to rule them all.

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.