Play many youtube short video in one go
YouTube Shorts Player
document.querySelectorAll(".urlInput");
const videoContainer = document.getElementById("videoContainer");
videoContainer.innerHTML = ""; // Clear previous videos
urls.forEach(urlInput => {
const url = urlInput.value.trim();
if (url) {
const videoId = extractVideoId(url);
if (videoId) {
const iframe = document.createElement("iframe");
iframe.src = `https://www.youtube.com/embed/${videoId}?autoplay=1&playlist=${videoId}&loop=1`;
iframe.allow = "autoplay; encrypted-media; picture-in-picture";
iframe.allowFullscreen = true;
videoContainer.appendChild(iframe);
}
}
});
document.getElementById("audioOptionContainer").style.display = "block"; // Show audio options
}
function extractVideoId(url) {
const match = url.match(/(?:youtube\.com\/shorts\/|youtube\.com\/watch\?v=|youtu\.be\/)([^&?/]+)/);
return match ? match[1] : null;
}
function toggleAudio(playWithAudio) {
const iframes = document.querySelectorAll("#videoContainer iframe");
iframes.forEach(iframe => {
let src = iframe.src.split("&mute=1")[0].split("&mute=0")[0]; // Remove existing mute settings
iframe.src = `${src}&mute=${playWithAudio ? 0 : 1}`; // Mute or unmute based on selection
});
}
]]>
0 Response to "Play many YouTube Short in one Go"
Post a Comment