samples-server icon indicating copy to clipboard operation
samples-server copied to clipboard

Is there a way for this video stream to work on iOS?

Open sehsarah opened this issue 4 years ago • 3 comments

This example -

https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Taking_still_photos https://mdn-samples.mozilla.org/s/webrtc-capturestill/

On iOS Safari, you open the example, it prompts for webcam use, you allow, then it takes a single frame and stays that way, doesn't open a video stream

Do you have more information on this and whether there's potential for this same webpage to work on iOS somehow?

Thank you! :)

sehsarah avatar Apr 06 '20 06:04 sehsarah

Hi,

I had the same problem and stumpled upon this. A solution that worked for me was:

  1. Make sure your website is called via HTTPS. (else you need to activate the options in the safari developer tools that WebRTC is allowed on 'unsafe' websites)
  2. Set the "playsinline"-attribute of the video object to true:
navigator.mediaDevices.getUserMedia({video: true, audio: false})
     .then(function(stream) {
        video.srcObject = stream;
        video.setAttribute("playsinline", true);  // <-- this is the important line
        video.play();
    })

Hope it helps!

weigangd avatar Apr 08 '20 14:04 weigangd

This worked! Thanks so much @Nako11 💯

Should you make a Pull Request for this to be added to the example in this repo? Unsure what the etiquette is to close this Issue or leave it open so others can find it easily.

Thanks so cool!!! 🎉

sehsarah avatar Apr 08 '20 23:04 sehsarah

Glad it helped :)

I don't know the etiquette either but I created a pull request and maybe @a2sheppy will see it.

I think you should leave this Issue open until the fix is merged.

weigangd avatar Apr 09 '20 08:04 weigangd