javascriptiossafarigetusermediamediadevices

Safari on iOS not allowing for video and video preview


I am running into issues on an iPad using Safari with a video chat app. I am trying to show the user's video feed, and give them the ability to change their camera in the sidebar with a preview, however when trying to view other sources, the original camera feed goes black. This appears to happen any time navigator.mediaDevices.getUserMedia() is called.

My code for getting devices:

navigator.mediaDevices.getUserMedia({video: true})
.then(function(stream) {
  /* use the stream */
    console.log(stream)
})
.catch(function(err) {
  /* handle the error */
    console.log(err)
});

Is it possible to run this function without losing the original video feed? Thanks!


Solution

  • Mobile Safari only permits one camera at a time to be visible with .getUserMedia(). If you get a new stream, the old one stops.