Saltar al contenido
mayo 25, 2025
<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Video con Carga Realista</title>
  <style>
    body {
      margin: 0;
      background: #000;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 100vh;
    }

    .video-container {
      position: relative;
      width: 640px;
      height: 360px;
    }

    video {
      width: 100%;
      height: 100%;
      background: #000;
    }

    .loading-overlay {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0, 0, 0, 0.8);
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      color: white;
      font-size: 18px;
      z-index: 10;
      display: none;
    }

    .spinner {
      border: 6px solid #f3f3f3;
      border-top: 6px solid #3498db;
      border-radius: 50%;
      width: 50px;
      height: 50px;
      animation: spin 1s linear infinite;
      margin-bottom: 15px;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }
  </style>
</head>
<body>

<div class="video-container">
  <video id="miVideo" src="https://www.w3schools.com/html/mov_bbb.mp4" controls></video>
  <div id="cargando" class="loading-overlay">
    <div class="spinner"></div>
    Cargando...
  </div>
</div>

<script>
  const video = document.getElementById('miVideo');
  const overlay = document.getElementById('cargando');

  video.addEventListener('play', () => {
    overlay.style.display = 'flex'; // Mostrar el spinner
    setTimeout(() => {
      overlay.style.display = 'none'; // Ocultarlo después de 3 segundos
    }, 3000);
  });

  video.addEventListener('ended', () => {
    overlay.style.display = 'none';
  });
</script>

</body>
</html>