Skip to content
This repository has been archived by the owner on Apr 27, 2021. It is now read-only.

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

Open
sehsarah opened this issue Apr 6, 2020 · 3 comments · May be fixed by #95
Open

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

sehsarah opened this issue Apr 6, 2020 · 3 comments · May be fixed by #95

Comments

@sehsarah
Copy link

sehsarah commented Apr 6, 2020

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! :)

@weigangd
Copy link

weigangd commented Apr 8, 2020

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!

@sehsarah
Copy link
Author

sehsarah commented Apr 8, 2020

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!!! 🎉

@weigangd weigangd linked a pull request Apr 9, 2020 that will close this issue
@weigangd
Copy link

weigangd commented Apr 9, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants