iOS 11 getUserMedia not working?
Solved it by using the following:
$(function () {
video = document.getElementById('vid');
video.style.width = document.width + 'px';
video.style.height = document.height + 'px';
video.setAttribute('autoplay', '');
video.setAttribute('muted', '');
video.setAttribute('playsinline', '');
var constraints = {
audio: false,
video: {
facingMode: 'user'
}
}
navigator.mediaDevices.getUserMedia(constraints).then(function success(stream) {
video.srcObject = stream;
});
});
mediaDevices.getUserMedia not working with Safari 11 in iOs 11 (video is black)
The problem is not in API as you said, it's because mobile browser needs a valid click
event to start playing video, so video.play()
will not work on mobile without user interaction. For example, this post is proving it: https://stackoverflow.com/a/16860922/6053654. What I usually do: I just add play
icon over the video (only on mobile) to induce user to click, and then, I bind video.play()
to this click
event. Sounds simple.
iOS 11 Public beta 5 getUserMedia not working
getUserMedia requires HTTPS unless you use the "allow media capture on insecure sites" shown in the first screenshot of this webkit blog post
Related Topics
How to Scroll to Top on Route Change with React Router Dom V6
Internet Explorer Adds Height- and Width-Attributes to a Newly Appended Image Automatically
Infinite Rotation Animation Using CSS and JavaScript
How to Prevent iOS Safari Alert When Trying to Open Non-Installed Native App
Fastest Way to Preload/Load Large Images
How to Conditionally Change CSS Styles with Js
Onclick Show Div, But Hide When Other One Is Clicked
Wkwebview Evaluate JavaScript Return Value
Click Event Doesnt Work in Safari Mobile for Some HTML Content
How to Set the Margin of an Object in Ie
Ios9: Try to Open App via Scheme If Possible, or Redirect to App Store Otherwise
How to Detect When the iPhone Goes into Landscape Mode via JavaScript? Is There an Event for This
Where in the HTML File Should Jquery and Bootstrap Be Placed
Add Page-Specific JavaScript or CSS in Joomla
Angular: Why Doesn't CSS Justification Work with Ng-Repeat
How to See the JavaScript Errors of Phonegap App in Xcode
Window.Scrollto Not Working in Phonegap - Alternative Solution or Workaround