addyosmani / getUserMedia.js

Shim for getUserMedia(). Uses native implementation for modern browsers and a Flash fallback for everyone else.
MIT License
903 stars 158 forks source link

Fixed flash fallback on Safari #46

Closed yueranyuan closed 8 years ago

yueranyuan commented 9 years ago

Flash object across browsers behave in different ways. Most notably IE uses ActiveX and require a "classid" and a "movie" param. See http://alistapart.com/article/flashembedcagematch for details.

Having classid as a field seems to break Safari compatibility so I added an 'if IE' conditional.

Haven't compiled the dist files and the html injection is in multiple lines. This is for ease of review; if the author thinks this PR is an appropriate solution then I'll put up a patch with compiled files and the works.

Further recommended changes that I can make if the author approves:

yueranyuan commented 9 years ago

Response to issue https://github.com/addyosmani/getUserMedia.js/issues/38

addyosmani commented 9 years ago

@ponyfleisch @dandv how comfortable would you be with this fix addressing the issue you ran into with #38? Thanks for putting the PR together @yueranyuan!

IanYates commented 9 years ago

This may break IE 10 & 11 - see https://msdn.microsoft.com/library/hh801214(v=vs.85).aspx

Conditional comments just aren't recognised by IE 10 and 11 anymore (too many sites used them to feed IE6 style code to the browser when IE 10/11 would render the modern version just fine)

addyosmani commented 9 years ago

@IanYates You're right. If we end up crafting a solution here we should be keeping in mind a balance of support between oldIE and more recent versions.

yueranyuan commented 9 years ago

good point @IanYates, I don't have a windows machine w/ webcam so I haven't tested it myself. But I've asked someone to test it and their IE11 appears to be able to run the site. Can anyone with IE10 or 11 confirm?

Alternatively we can use swfobject https://code.google.com/p/swfobject/wiki/documentation It is speculated that SwfObject2.1 is compatible with new/old IE and Safari (SwfObject2.2 allegedly breaks some compatibility)

IanYates commented 9 years ago

I'm on a Windows machine with a webcam running IE11 :) This polyfill has worked a treat in desktop and "Metro" IE even on a Surface RT (since it has flash).

What site do you want me to visit? I don't have older versions of IE myself (and we explicitly don't support them) but I'll happily be your arms & legs to try things out on various sites with IE 11.

yueranyuan commented 9 years ago

Ah excellent @IanYates ,

By site I was referring to the face-detection-demo. Were you able to run that?

IanYates commented 9 years ago

Oh yeah, it works just fine. It's because it worked in IE so well (Metro & Desktop) that I started using this library (and watching GitHub discussions).

capture

yueranyuan commented 9 years ago

Gotcha, have you tried this PR on IE10 or 11? (Just checking because I'm not sure if your image from the above post relates to the library as a whole or this PR)

IanYates commented 9 years ago

No I haven't tried the PR - sorry I wasn't clear. That image was just a screenshot from the demo website. I'm pretty flat out at the moment but will try to download and run the demo, or at least something like it. If you've got it somewhere already that I can just visit then I can visit and get back to you much faster instead

yueranyuan commented 9 years ago

I just emailed you a link to an AWS EC2 where I'm running this PR. Lemme know how it goes.

(I didn't want to post my dev server address to gh since as I think a lot of malicious web scrapers target gh for ip addresses)

IanYates commented 9 years ago

Success!

That works in both IE 11 and Metro IE on my Win 8.1 laptop :) That's good enough for me! I have Win 10 on an old Samsung tablet (the type they gave out at the original //Build) so I'll try both versions on there too. If I remember correctly I think Spartan/Edge is building in native support for getUserMedia anyway.

I've just noticed that Adobe flash in Metro has changed since the last time I played with it. There's no easy ability to right-click it and change cameras, etc. That behaviour is the same in both the original demo and yours so the change is due to MS/Adobe.

addyosmani commented 8 years ago

Hey folks. As far as testing goes, this change appears to be good to bring in. Would @IanYates or someone else like to confirm whether there's any outstanding behaviour worth us holding back on bringing this in for?

IanYates commented 8 years ago

Ummm, I guess it's OK. I had forgotten all about this :) @yueranyuan sent me a link and it looks like I was happy with the outcome :100:

sojiya commented 7 years ago

HI, am using this one for my site. I have an issue on mobile devices can anyone help me? Issue: The captured image displaying like flipped. actual image rotated with 180deg.