When you click on the Red play, the video from the Blue play starts playing.
Sometimes no video is playing, and you can hear the video from the Blue play, or the other way around.
How it should work
After clicking on the Red play, the video to the red starts playing right away.
After clicking on the Blue play, the video to the blue starts playing right away.
How would I be able to get this to work properly?
I am having difficulty trying to figure this out.
When testing the JSitor codes, Click Run not update
To reproduce issue, click either the Red play or the Blue play.
Click Run to reset then do it again.
1st Attempt https://jsitor.com/4C2KipqHmJ
https://jsfiddle.net/e5at9dxr/
function onYouTubeIframeAPIReady() {
const cover = document.querySelectorAll(".playa, .playb");console.log(cover);
cover.forEach(function (cover) {
const wrapper = cover.parentElement;
const frameContainer = wrapper.querySelector(".video");
videoPlayer.addPlayer(frameContainer);
const covers = document.querySelectorAll(".thePlay");
covers.forEach(function (cover) {
cover.addEventListener("click", coverClickHandler);
});
}());
2nd Attempt https://jsitor.com/YI3Onmxzd
https://jsfiddle.net/pahL5o0k/
function onYouTubeIframeAPIReady() {
const cover = document.querySelectorAll(".playa, .playb");console.log(cover);
cover.forEach(function (cover) {
const wrapper = cover.parentElement;
const frameContainer = wrapper.querySelector(".video");
videoPlayer.addPlayer(frameContainer);
const covers = document.querySelectorAll("svg.playa, svg.playb");
covers.forEach(function (cover) {
cover.addEventListener("click", coverClickHandler);
});
}());
html
<div class="outer">
<div class="container with-curtain">
<svg class="playa thePlay" width="100%" height="100%" viewBox="0 0 64 64">
<path d="M25.6,46.4L44.8,32L25.6,17.6V46.4z M32,0C14.3,0,0,14.3,0,32s14.3,32,32,32s32-14.3,32-32S49.7,0,32,0z
M32,57.6C17.9,57.6,6.4,46.1,6.4,32S17.9,6.4,32,6.4S57.6,17.9,57.6,32S46.1,57.6,32,57.6z" />
</svg>
<div class="inner-container curtain curtain1">
<div class="ratio-keeper">
<div class="wrapa">
<div class="video video-frame" data-id="qe5WF4qCSkQ"></div>
</div>
<div class="panel-left"></div>
<div class="panel-right"></div>
</div>
</div>
</div>
<div class="container with-curtain">
<svg class="playb thePlay " width="100%" height="100%" viewBox="0 0 64 64">
<path d="M25.6,46.4L44.8,32L25.6,17.6V46.4z M32,0C14.3,0,0,14.3,0,32s14.3,32,32,32s32-14.3,32-32S49.7,0,32,0z
M32,57.6C17.9,57.6,6.4,46.1,6.4,32S17.9,6.4,32,6.4S57.6,17.9,57.6,32S46.1,57.6,32,57.6z" />
</svg>
<div class="inner-container curtain curtain2">
<div class="ratio-keeper">
<div class="wrapa">
<div class="video video-frame" data-id="2VwsvrPFr9w"></div>
</div>
<div class="panel-left"></div>
<div class="panel-right"></div>
</div>
</div>
</div>
</div>