I’m trying to develop a webrtc video call system between mobile devices and computers. The mobile device sends the video stream of his to the computer.
In the mobile device the UI only shows the video it is recordings via its camera, in android this all works great but in iOS (I tested with 2 different iphones with the latest iOS version) the video doesn’t get started and it shown as black thought it gets transmitted to the computer without problems.
I tried everything I found online, adding controls to the video element, removing the controls, adding autoplay playsinline..., requesting the getUserMedia unload and reproducing the stream based on an user gesture, but nothing seems to work and I don't even get any errors on the console of the mobile phone. I tested on different browsers safari and chrome. And for more weirdness sometimes it starts when going to the list of tabs you have open on the browser and you go back to the page
This is the code of the video element
<video class='user-virtual-assessment-video' id='virtualAssessmentVideo' autoplay muted playsinline>
</video>
<button id='startVirtualAssessment' class='action-button'>
<svg ...>
</button>
And the code executed when the user clicks on the button
e.stopPropagation();
e.preventDefault();
const videoElement = document.getElementById('virtualAssessmentVideo')
videoElement.srcObject = stream;
videoElement.play()
startVirtualAssessment()
The function startVirtualAssessment basically starts the rtc connection, and the user media of the iPhone gets requested on page load and stored on the stream variable
navigator.mediaDevices.getUserMedia({video: { facingMode: 'environment', aspectRatio: {exact: 16/9}, frameRate: { ideal: 10, max: 15 } }}).then((streamObject) => {
stream = streamObject;
})
Maybe there's something obvious that I'm missing or not understanding but I don't really see the problem with the code.
Thanks a lot :)