Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11.3 Camera access via getUserMedia and black screens

Now that iOS 11.3 is out with the updated version of Safari.

Has anybody been able to successfully use the getUserMedia APIs to display the camera output onto a canvas?

e.g We've opened both

https://simpl.info/getusermedia/

and

https://webrtc.github.io/samples/src/content/getusermedia/canvas/

in Safari, they both ask for access to the camera - however, neither of them render anything but a black square

e.g

screenshot of the issue

like image 586
owenmelbz Avatar asked Dec 07 '22 15:12

owenmelbz


1 Answers

Adding a playsinline attribute to the relevant <video> tag should do the trick:

var video = document.getElementById("video-element");    
video.setAttribute("playsinline", true);

I've also found this bug difficult to replicate. And judging from the comments above, I'm not sure it's due to iOS version changes alone. Moreover, I'm unable to find any official documentation on the topic.

Nonetheless, here is some related reading material:

See this issue on GitHub

And this StackOverflow question: iOS 11 getUserMedia not working?

Edit: The WebKit BugZilla thread was mentioned in the GitHub issue I referenced above, which seems to be the closest thing to "official documentation" available.

like image 135
jknotek Avatar answered Dec 11 '22 10:12

jknotek