Is Video Picture-in-Picture Blocked on Safari with WebRTC?

I'm currently developing a WebRTC user interface that displays the user's video in a small window positioned in front of the person they are speaking to.

Feel free to check out the working codepen example here:

https://codepen.io/VikR/pen/GXoXRp

CSS

#pipContainer {
    position: relative;
    top: 0;
    left: 0;
  width: 250px;
}

#otherCallerVideo  {
    position: relative;
    top: 0;
    left: 0;
  width: 100%;
}

#myVideo {
    width: 30%;
    position: absolute;
    bottom: 0;
    right: 0;
    transform: rotateY(-180deg);
    z-index: 1000;
}

HTML

  <p id="status">Loading room information...</p>

  <div id="start">
    <button  onclick="start(event)">Start</button><br/>
  </div>

  <div id="pipContainer">
    <video id="otherCallerVideo" playsInline="true" autoPlay></video>
    <video id="myVideo" playsInline="true" autoPlay muted></video>
  </div>

While this setup works smoothly on Chrome and Firefox, it seems Safari on OS X and iOS does not allow it. The user's video disappears in Safari. I have experimented with various methods including z-index and different positioning techniques, but so far no luck in getting it to work on Safari.

Is there a way to achieve this functionality in Safari?

Answer №1

After some trial and error, I finally got it to work! Check out the updated CodePen below:

https://codepen.io/VikR/pen/Wgwwoa

The key solution was including this piece of overflow code in the video container:

#pipContainer {
  position: relative;
  width: 300px;
  height: 300px;
  border: 5px solid black;
  overflow: scroll;
  -webkit-overflow-scrolling: touch;
}

This issue was quite tricky to pinpoint. Researching "safari z-index video elements" brought up various related discussions from 2011 to 2018 and many suggested fixes didn't seem to apply in my case, possibly due to overlaying one video on top of another. The successful fix that did the trick was located here.

Additional Notes:
overflow: 'hidden' is also effective and removes the scrollbars.
It seems adjusting video dimensions through javascript might not be feasible. In my application, I currently set them during HTML rendering based on screen.height.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Changing the border color of a Material UI textbox is overriding the default style

Upon the initial page load, I expected the border color of the text box to be red. However, it appeared grey instead. I tried setting the border color to red for all classes but the issue persisted. Even after making changes, the border color remained unch ...

Issue encountered: difficulty with vertical alignment in table cell containing both text input and image

I am facing an issue with aligning two items (an input text and an image) within a cell of a table. Despite trying various methods like using vertical-align:middle, margin top, padding, and setting height to 100%, I haven't been able to achieve the de ...

How to Implement Loading Image with CSS

I have customized the CSS code below to style a div element that showcases a responsive image. .my-img-container { position: relative; &:before { display: block; content: " "; background: url("https://lorempixel.com/300/160/") ...

Is there a way to use the same background image for both the left and right borders?

How can I set this image as both the left and right background image on my webpage? I want it to be displayed on both sides. Any suggestions on how to achieve this? Here is the code snippet I have implemented so far: <%@ Page Language="C#" AutoEventW ...

iOS function _nw_parameters_configure_protocol_disable has been called directly

I am attempting to utilize a TCP Socket within a common module in iOS Kotlin/Native. According to Apple's documentation, opening a nw_connection_t is as simple as: val connection = nw_parameters_create_secure_tcp( NW_PARAMETERS_DISABLE_PR ...

Swap the image when hovering over it

Is it possible to modify this specific code so that a hover effect is triggered on mouseover? I attempted to look into similar questions and answers, but I found them difficult to understand. Here is the HTML snippet: <a href="RR.html"><img src ...

Having trouble getting jQuery to function properly in Safari

I am facing an issue with jQuery in the Safari browser. While my jQuery functions are functioning perfectly on GC, FF, IE, and Opera, they seem to fail when tested on Safari. My question is: Is there a specific code snippet that I can integrate into my w ...

The page width seems incredibly wide right now, and I'm having trouble pinpointing which CSS element is responsible for this

My website is on Wordpress and the page widths seem to be too wide. I have tried looking for the culprit in the code, but so far no luck... ...

The phenomenon of an invisible Absolute or relative position leading to grid components overlapping in Next.js

I've been struggling with this issue for over 48 hours now. I've attempted to troubleshoot by commenting out everything except the affected components and even swapping entire components around, but the problem persists. Oddly enough, rearranging ...

Transfer the div above to the other div

My dynamic set of divs have varying heights generated dynamically even though their widths are fixed. Despite setting them to float:left, they are not aligning perfectly under each other. The divs are forming rows with the height of the row being determine ...

Stop the div from collapsing when hiding or deleting all child elements to maintain its structure

I have recently developed a Vuetify application that manages card items. To ensure security and accessibility, I have added a feature where the actions/buttons are displayed based on the User's permissions. In case of missing permissions, these button ...

"Implementing a feature to apply the 'current' class to a div

How can I dynamically add a current class to the .navimg divs (next to li) when their parent link is clicked? Sample HTML: <div id="navbox"> <ul id="navigation"> <li id="home"><a href="#">HOME</a></li> ...

The Scene Kit object showing dysfunction in rotation

I'm having trouble getting my Scene Kit node to rotate properly. The goal is for it to rotate around the y-axis. The object in question is a sphere. let node = SCNNode() node.geometry = SCNSphere(radius: 1) node.geometry?.firstMaterial?.diffuse.cont ...

When I tried to open a website using the "target=_blank" attribute on the Chrome mobile version for iPhone, I noticed some strange viewport behavior

[Update] I encountered the following issue: I once had a website. It functioned well, except when opened in a new tab with target "_blank." When accessing the site directly, everything appeared normal enter image description here However, when accessed ...

Dynamic web design: leverage variable font sizes in the DOM

I'm having trouble adjusting the font size using a variable in my code. Can anyone pinpoint the issue? Link to the code snippet <div id = "letter"> <span>A</span> <span>l</span> <span>p</span> ...

Ensuring Uniform Column Height in Bootstrap 4 - Preventing Buttons from Being Forced to the Bottom of

Using the Bootstrap 4 class 'h-100' to ensure equal height for all three columns, I encountered an issue where the buttons that were initially aligned to the bottom of each div are no longer in correct alignment. How can I maintain button alignme ...

Troubining CSS nth-of-type or child selectors with custom elements within additional custom elements may cause unexpected behavior

Struggling with CSS :nth-child and creating a unique layout with custom elements inside custom elements. The issue arises when trying to display different icons using the :before pseudo-element, but all icons end up being the same. Below is the code snippe ...

Footer remains fixed and scrolls into the body when the window is resized

Having trouble with the footer's responsiveness when resizing the desktop window. It looks fine in developer tools, but in different browsers, the footer placement gets messed up and scrolls over the rest of the content. Any insights on what might be ...

When would using <style> be more appropriate than using a css file?

Is it necessary to use the style element when you can simply write in the CSS file? Are there any circumstances where using 'style' is more beneficial than the CSS file? ...

Tips for aligning an HTML button with a hyperlink

<form method="get" action=https://www.wwf.de/spenden-helfen/allgemeine-spende> <button type="submit">Donate Now</button> I am facing an issue where the button is appearing randomly on my website, but I need it to ...