Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pt-br">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Loop YouTube Videos</title>
- <!-- Link para Google Material Icons -->
- <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
- <style>
- body {
- font-family: Arial, sans-serif;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- height: 100vh;
- margin: 0;
- background-color: #f0f0f0;
- }
- h1 {
- color: #333;
- }
- .container {
- text-align: center;
- }
- .input-container {
- display: flex;
- justify-content: center;
- align-items: center;
- margin-bottom: 10px;
- }
- input[type="text"] {
- width: 300px;
- padding: 8px 12px; /* Ajustando o padding para ficar alinhado */
- border: 1px solid #ccc;
- border-radius: 5px 0 0 5px;
- outline: none;
- font-size: 16px;
- }
- button {
- padding: 6px 12px; /* Alinhando o padding do botão */
- background-color: #007BFF;
- color: white;
- border: none;
- border-radius: 0 5px 5px 0;
- cursor: pointer;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- button:hover {
- background-color: #0056b3;
- }
- .material-icons {
- font-size: 24px;
- }
- iframe {
- margin-top: 20px;
- border: none;
- }
- .hidden {
- display: none;
- }
- </style>
- </head>
- <body>
- <div class="container">
- <h1>Loop YouTube Vídeos</h1>
- <div class="input-container">
- <input type="text" id="youtubeUrl" placeholder="Cole a URL do vídeo do YouTube">
- <button onclick="embedVideo()">
- <span class="material-icons">search</span>
- </button>
- </div>
- <button id="copyButton" class="hidden" onclick="copyUrl()">Copiar URL do Vídeo</button>
- <div id="videoContainer"></div>
- </div>
- <script>
- let embedUrl = '';
- function embedVideo() {
- var url = document.getElementById('youtubeUrl').value;
- var videoId = extractVideoId(url);
- if (videoId) {
- embedUrl = `https://www.youtube.com/embed/${videoId}?autoplay=1&loop=1&playlist=${videoId}`;
- document.getElementById('videoContainer').innerHTML = `<iframe width="560" height="315" src="${embedUrl}" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>`;
- document.getElementById('copyButton').classList.remove('hidden'); // Mostrar o botão de copiar
- } else {
- alert('Por favor, insira uma URL válida do YouTube.');
- }
- }
- function extractVideoId(url) {
- var videoId = '';
- var urlParts = url.split(/(vi\/|v=|\/v\/|youtu\.be\/|\/embed\/)/);
- if (urlParts[2] !== undefined) {
- videoId = urlParts[2].split(/[^0-9a-z_-]/i)[0];
- } else {
- videoId = url;
- }
- return videoId;
- }
- function copyUrl() {
- navigator.clipboard.writeText(embedUrl).then(function() {
- alert("URL copiada para a área de transferência!");
- }, function() {
- alert("Falha ao copiar a URL.");
- });
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement