Reputation: 3886
I'm using navigator.mediaDevices.getUserMedia
and displaying the local media with a <video>
element. It works fine, except on my iPhone I see a black rectangle behind the video. How can I hide/remove the black rectangle?
Some things I've tried:
background: transparent
and background-color: transparent
overflow: hidden
But none worked. My iPhone is running iOS 15.0.2, but it was happening on iOS 14 as well.
Full source:
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
window.addEventListener('load', async () => {
try {
const localVideo = document.getElementById('localVideo');
localVideo.srcObject = await navigator.mediaDevices.getUserMedia({video: true});
} catch {
alert('Please allow camera and microphone access.');
}
});
</script>
</head>
<body>
<video autoplay playsinline muted id="localVideo" width=150></video>
</body>
</html>
Upvotes: 0
Views: 178
Reputation: 17295
This is likely a known regression in iOS 15.0 which is fixed in 15.1: https://bugs.webkit.org/show_bug.cgi?id=229792
Upvotes: 1